-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM alicehartmann.staffgroups sg LEFT JOIN alicehartmann.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
-QUERYARRAY: select id,trackername from alicehartmann.timetrackerconfig order by trackername
-QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from alicehartmann.staff st
-LEFT JOIN alicehartmann.staffgroups stg ON st.id_staffgroup = stg.id
-left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
- when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff)
-cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='alicehartmann') ttr
-where st.isdeleted is null order by groupname,surname,prename;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM alicehartmann.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERYARRAY: SELECT id,vacancyname,color
- FROM alicehartmann.vacancytypes where isworktime is null or isworktime=false order by vacancyname;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: select id,trackername from alicehartmann.timetrackerconfig order by trackername
-QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM alicehartmann.staffgroups sg LEFT JOIN alicehartmann.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
-QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from alicehartmann.staff st
-LEFT JOIN alicehartmann.staffgroups stg ON st.id_staffgroup = stg.id
-left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
- when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff)
-cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='alicehartmann') ttr
-where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM alicehartmann.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERYARRAY: SELECT id,vacancyname,color
- FROM alicehartmann.vacancytypes where isworktime is null or isworktime=false order by vacancyname;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM alicehartmann.staffgroups sg LEFT JOIN alicehartmann.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
-QUERYARRAY: select id,trackername from alicehartmann.timetrackerconfig order by trackername
-QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from alicehartmann.staff st
-LEFT JOIN alicehartmann.staffgroups stg ON st.id_staffgroup = stg.id
-left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
- when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff)
-cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='alicehartmann') ttr
-where st.isdeleted is null order by groupname,st.staffnumber::INT,surname,prename;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM alicehartmann.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERYARRAY: SELECT id,vacancyname,color
- FROM alicehartmann.vacancytypes where isworktime is null or isworktime=false order by vacancyname;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
-QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company,
- us.schemaaccess AS schemaname,
- cp.datasetname
- FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess
- FROM users WHERE users.isdeleted IS null) us
- LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select sessiondata from public.sessions where id='f2de1423-f891-08ee-f516-ec4b2ce4c0db'
-EXEC: update public.sessions set sessiondata='{"schemata":"kraeltgen"}' where id='f2de1423-f891-08ee-f516-ec4b2ce4c0db'
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: select id,trackername from kraeltgen.timetrackerconfig order by trackername
-QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM kraeltgen.staffgroups sg LEFT JOIN kraeltgen.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
-QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from kraeltgen.staff st
-LEFT JOIN kraeltgen.staffgroups stg ON st.id_staffgroup = stg.id
-left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
- when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff)
-cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='kraeltgen') ttr
-where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
-QUERYARRAY: SELECT id,vacancyname,color
- FROM kraeltgen.vacancytypes where isworktime is null or isworktime=false order by vacancyname;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM kraeltgen.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: select id,trackername from kraeltgen.timetrackerconfig order by trackername
-QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM kraeltgen.staffgroups sg LEFT JOIN kraeltgen.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
-QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from kraeltgen.staff st
-LEFT JOIN kraeltgen.staffgroups stg ON st.id_staffgroup = stg.id
-left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
- when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff)
-cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='kraeltgen') ttr
-where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM kraeltgen.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: select id,trackername from kraeltgen.timetrackerconfig order by trackername
-0) AS staffmembers FROM kraeltgen.staffgroups sg LEFT JOIN kraeltgen.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
-QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from kraeltgen.staff st
-LEFT JOIN kraeltgen.staffgroups stg ON st.id_staffgroup = stg.id
-left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
- when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from kraeltgen.staffcontract group by id_staff) sc on (st.id=sc.id_staff)
-cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='kraeltgen') ttr
-where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
-QUERYARRAY: SELECT id,vacancyname,color
- FROM kraeltgen.vacancytypes where isworktime is null or isworktime=false order by vacancyname;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM kraeltgen.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select * from kraeltgen.staff where id='f18a67e3-1b2f-dbed-85e9-1b35912f943e' and isdeleted is null;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
- to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
- to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
- --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
- to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
- to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
- to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
- to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
- to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
- to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
- case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
- to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
- srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
- COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
- st.id_staffgroup, sgr.groupname,
- case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
- case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
- case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
- ,itmcontracthours,maxdays,srp.isvalidated,
- to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
- to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
- to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
- to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
- to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
- to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
- to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
- FROM kraeltgen.staffreportperiod srp
- LEFT JOIN kraeltgen.staff st ON srp.id_staff = st.id
- LEFT JOIN kraeltgen.reportperiod rp ON srp.id_reportperiod = rp.id
- LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id
- WHERE st.isdeleted IS NULL AND srp.id_staff = 'f18a67e3-1b2f-dbed-85e9-1b35912f943e'
- ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
-QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f18a67e3-1b2f-dbed-85e9-1b35912f943e' order by vacyear;
-QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from kraeltgen.staffcontract where id_staff='f18a67e3-1b2f-dbed-85e9-1b35912f943e' order by startdate,enddate;
-QUERYARRAY: select to_char(daydate,'YYYY') as vacyear,daydate,
- to_char(vacancyhours::interval,'HH24:MI') as vacancyhours,
- to_char(vacillhours::interval,'HH24:MI') as vacillhours,
- to_char(vacextrahours::interval,'HH24:MI') as vacextrahours,
- coalesce ('<div>' || vacancycomment || '</div>','') || coalesce('<div>' || vacillcomment|| '</div>','') || coalesce('<div>' || vacextracomment|| '</div>','') as description
- from kraeltgen.staffreportperioddays where (vacancyhours is not null or vacillhours is not null or vacextrahours is not null) and id_staff='f18a67e3-1b2f-dbed-85e9-1b35912f943e' order by daydate;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
-QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company,
- us.schemaaccess AS schemaname,
- cp.datasetname
- FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess
- FROM users WHERE users.isdeleted IS null) us
- LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM kraeltgen.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl,to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM kraeltgen.reportperiod rp ORDER BY startdate, enddate;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company,
- us.schemaaccess AS schemaname,
- cp.datasetname
- FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess
- FROM users WHERE users.isdeleted IS null) us
- LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;
-QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select sessiondata from public.sessions where id='f2de1423-f891-08ee-f516-ec4b2ce4c0db'
-EXEC: update public.sessions set sessiondata='{"schemata":"davincenzo"}' where id='f2de1423-f891-08ee-f516-ec4b2ce4c0db'
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company,
- us.schemaaccess AS schemaname,
- cp.datasetname
- FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess
- FROM users WHERE users.isdeleted IS null) us
- LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl,to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM davincenzo.reportperiod rp ORDER BY startdate, enddate;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM davincenzo.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERYARRAY: SELECT id,vacancyname,color
- FROM davincenzo.vacancytypes where isworktime is null or isworktime=false order by vacancyname;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
-QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company,
- us.schemaaccess AS schemaname,
- cp.datasetname
- FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess
- FROM users WHERE users.isdeleted IS null) us
- LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM davincenzo.staffgroups sg LEFT JOIN davincenzo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
-QUERYARRAY: select id,trackername from davincenzo.timetrackerconfig order by trackername
-QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from davincenzo.staff st
-LEFT JOIN davincenzo.staffgroups stg ON st.id_staffgroup = stg.id
-left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
- when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from davincenzo.staffcontract group by id_staff) sc on (st.id=sc.id_staff)
-cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='davincenzo') ttr
-where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM davincenzo.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERYARRAY: SELECT id,vacancyname,color
- FROM davincenzo.vacancytypes where isworktime is null or isworktime=false order by vacancyname;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
-QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company,
- us.schemaaccess AS schemaname,
- cp.datasetname
- FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess
- FROM users WHERE users.isdeleted IS null) us
- LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM davincenzo.staffgroups sg LEFT JOIN davincenzo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
-QUERYARRAY: select id,trackername from davincenzo.timetrackerconfig order by trackername
-QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from davincenzo.staff st
-LEFT JOIN davincenzo.staffgroups stg ON st.id_staffgroup = stg.id
-left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
- when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from davincenzo.staffcontract group by id_staff) sc on (st.id=sc.id_staff)
-cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='davincenzo') ttr
-where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
-QUERYARRAY: SELECT id,vacancyname,color
- FROM davincenzo.vacancytypes where isworktime is null or isworktime=false order by vacancyname;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM davincenzo.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company,
- us.schemaaccess AS schemaname,
- cp.datasetname
- FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess
- FROM users WHERE users.isdeleted IS null) us
- LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;
-QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: SELECT * FROM public.companies WHERE schemata='davincenzo' and isdeleted IS NULL;
-QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
- coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
- FROM davincenzo.workplans wp
- ORDER BY wp.isdefault, wp.workplan;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company,
- us.schemaaccess AS schemaname,
- cp.datasetname
- FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess
- FROM users WHERE users.isdeleted IS null) us
- LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo';
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: SELECT * FROM public.companies WHERE schemata='davincenzo' and isdeleted IS NULL;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
- join users us on (us.id=se.id_user)
- left join usergroups ugrp on (ugrp.id=us.id_usergroup)
- where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and
- us.isblocked is null group by se.id,us.id,ugrp.id;
-QUERYARRAY: select * from (
-SELECT us.username,us.isblocked,us.surname,us.prename,us.id_company,us.id_usergroup,us.id,cp.company,cp.datasetname,grp.groupname,us.lang,
-case when us.id_usergroup = 'teamleader' then string_agg(stgrp.groupname,',') else null end as staffgroups,
- json_array_elements_text(us.schemaaccess) AS xschema
- FROM public.users us join public.companies cp on (us.id_company=cp.id)
- left join public.usergroups grp on (us.id_usergroup=grp.id)
- left join (select stu.id as id_user,stu.id_staffgroup,stg.groupname from davincenzo.staffgroups stg
-join (select id,json_array_elements_text(id_staffgroups) as id_staffgroup from public.users) stu on (stu.id_staffgroup=stg.id)) stgrp on (us.id=stgrp.id_user)
- WHERE us.isdeleted IS null and id_usergroup in ('teamleader','manager') group by us.id,cp.id,grp.id
- ) xus where xschema='davincenzo' group by xus.id,xus.username,xus.groupname,xus.isblocked,xus.surname,xus.prename,xus.id_company,xus.id_usergroup,xus.company,xus.datasetname,xus.xschema,xus.staffgroups,xus.lang;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff)
+ VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64';
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear)
+ select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by id_staff,vyear order by id_staff,vyear
+ on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours)
+SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause,
+ '08:00:00' as wdcontracthours
+FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday
+do update set wdcontracthours = '08:00:00';
+EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27'))
+ OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06'));
+EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in (
+select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate)
+where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id);
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64')
+ where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: insert into hotelplacedarme.workplandays (id_workplan,weeknum,weekday) values ('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,1),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,2),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,3),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,4),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,5),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,6),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,7);
+EXEC: UPDATE hotelplacedarme.workplandays SET start1='10:00', end1='14:30', start2='18:30', end2='23:00', pause='01:00', pausestart1='14:30', pauseend1='15:00', pausestart2='18:00', pauseend2='18:30' WHERE id='42821461-29d4-172f-acc1-92b3a1267a09';
+EXEC: UPDATE hotelplacedarme.workplans SET weekhours='08:00:00', weekdays=1, freeweekdayslist='["2","3","4","5","6","7"]' WHERE id='87b492b8-d8b9-58bf-a33e-8704bbf02d46'
+EXEC: UPDATE hotelplacedarme.workplandays SET start1='15:00', end1='23:45', start2=null, end2=null, pause='00:45', pausestart1='18:00', pauseend1='18:45', pausestart2=null, pauseend2=null WHERE id='2bcb11d6-3ff6-c50d-cd2d-c5e18625a78d';
+EXEC: UPDATE hotelplacedarme.workplans SET weekhours='16:00:00', weekdays=2, freeweekdayslist='["3","4","5","6","7"]' WHERE id='87b492b8-d8b9-58bf-a33e-8704bbf02d46'
+EXEC: update hotelplacedarme.workplandays set start1='10:00:00',end1='14:30:00',start2='18:30:00',end2='23:00:00', pause='01:00:00',pausestart1='14:30:00',pauseend1='15:00:00',pausestart2='18:00:00',pauseend2='18:30:00' where id='6ecb801e-e22e-0929-36ff-1f5f6c240656';
+EXEC: update hotelplacedarme.workplandays set start1='10:00:00',end1='14:30:00',start2='18:30:00',end2='23:00:00', pause='01:00:00',pausestart1='14:30:00',pauseend1='15:00:00',pausestart2='18:00:00',pauseend2='18:30:00' where id='b8fe5978-7738-8cc5-dc6b-ee185bc7199f';
+EXEC: update hotelplacedarme.workplandays set start1='15:00:00',end1='23:45:00',start2=null,end2=null, pause='00:45:00',pausestart1='18:00:00',pauseend1='18:45:00',pausestart2=null,pauseend2=null where id='c3ff2b72-351d-977f-cbc2-80244a53981e';
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='27c5fbb5-6652-5ed8-e20d-7ab64990600c';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2021-12-29') and id not in ('d5c0270b-3a52-c2fe-8e5b-f7aadd3cf4f1');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='08:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='27c5fbb5-6652-5ed8-e20d-7ab64990600c';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2021-12-29') and id not in ('d5c0270b-3a52-c2fe-8e5b-f7aadd3cf4f1');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='08:00:00', timeend1='14:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='8ed915d8-32a5-7e02-c8c5-5567af8b8ec7';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-03') and id not in ('995c3aca-6068-3bad-4d4b-53ca54304dee');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('09239728-30b0-9a1e-f0d5-44f2799cd539');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('09239728-30b0-9a1e-f0d5-44f2799cd539')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:30',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='09239728-30b0-9a1e-f0d5-44f2799cd539';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-04') and id not in ('481c4e96-0cbb-db56-87f9-c9883ec5c425');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:30',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-05') and id not in ('acc9c6a9-c574-3cc7-2861-6fd3c98737ce');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='7cef9092-3fa7-edf7-7498-5780fc493dab';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-08') and id not in ('95266fa0-a445-02ba-f4f7-8db6a6f76396');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='9a660396-b21e-e809-5f68-10fd7d0075df';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-09') and id not in ('2b6f457e-141c-2c3b-dbfc-e273f84f2c25');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('f315c3da-946b-4ca0-7edb-472894284a7d');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('f315c3da-946b-4ca0-7edb-472894284a7d')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('f216ecb3-4a77-66e1-c16a-37868d3395ce');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('f216ecb3-4a77-66e1-c16a-37868d3395ce')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('ead44f77-116b-5f7f-8bea-86f580a530e8','4bd516eb-8cbf-5d8d-d391-331c68f16a1d');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('ead44f77-116b-5f7f-8bea-86f580a530e8','4bd516eb-8cbf-5d8d-d391-331c68f16a1d')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('3f9ba3ab-0694-d025-5e9c-9dc4a6914caa');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('3f9ba3ab-0694-d025-5e9c-9dc4a6914caa')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('2e682993-c269-51f0-4d30-4c2db2d5e762','2899eda8-0686-d58e-b9a4-4c09f64ece7f','6d25ffcd-6ec2-3829-8c95-fa3ddb64a5f8');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('2e682993-c269-51f0-4d30-4c2db2d5e762','2899eda8-0686-d58e-b9a4-4c09f64ece7f','6d25ffcd-6ec2-3829-8c95-fa3ddb64a5f8')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('2899eda8-0686-d58e-b9a4-4c09f64ece7f');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('2899eda8-0686-d58e-b9a4-4c09f64ece7f')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='2899eda8-0686-d58e-b9a4-4c09f64ece7f';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-21') and id not in ('df2117f0-b3a3-3ebf-e727-3de88bb88003');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('2899eda8-0686-d58e-b9a4-4c09f64ece7f');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('2899eda8-0686-d58e-b9a4-4c09f64ece7f')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='2899eda8-0686-d58e-b9a4-4c09f64ece7f';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-21') and id not in ('df2117f0-b3a3-3ebf-e727-3de88bb88003');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='18:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='106f81fb-df7e-41dd-6107-44043886d600';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-18') and id not in ('82064209-dded-589c-4426-69cde5859a80');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('1ad3ae56-459b-0fc7-89f3-41e61532f3bd');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('1ad3ae56-459b-0fc7-89f3-41e61532f3bd')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('c4149aba-7ed6-523c-286a-8ccde9a0ede9');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('c4149aba-7ed6-523c-286a-8ccde9a0ede9')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('46e7c116-d7d4-d824-68f8-47ef6cfac410','ac7083e4-19c5-d224-47f0-399b557b2792','3a74db40-6a2d-5efb-c3be-1ca21e25979f','f806b869-9ae6-6b70-fe9b-345ddff90a44');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('46e7c116-d7d4-d824-68f8-47ef6cfac410','ac7083e4-19c5-d224-47f0-399b557b2792','3a74db40-6a2d-5efb-c3be-1ca21e25979f','f806b869-9ae6-6b70-fe9b-345ddff90a44')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('e3f4112a-94b2-1ead-1f3a-ac608fea204a','474a18e1-f919-7d67-17f8-04be6e0e284f','b19f26b5-ff93-102d-2116-6dcc70837db3');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('e3f4112a-94b2-1ead-1f3a-ac608fea204a','474a18e1-f919-7d67-17f8-04be6e0e284f','b19f26b5-ff93-102d-2116-6dcc70837db3')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('4521fe02-581f-6184-39d6-c69ef3dc9526');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('4521fe02-581f-6184-39d6-c69ef3dc9526')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='a43190ec-87cc-e088-01dd-bab78db42043';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-02-04') and id not in ('');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1='14:00',pauseend1='14:30',pausestart2='18:30',pauseend2='19:00',payedpause=null,timepause='01:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='2e682993-c269-51f0-4d30-4c2db2d5e762';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-17') and id not in ('f749809f-b012-a59a-7501-1ae2af55b43d');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause='01:00:00', pausestart1='14:00:00', pauseend1='14:30:00', pausestart2='18:30:00', pauseend2='19:00:00', vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('4bd516eb-8cbf-5d8d-d391-331c68f16a1d','ead44f77-116b-5f7f-8bea-86f580a530e8','f315c3da-946b-4ca0-7edb-472894284a7d','7cef9092-3fa7-edf7-7498-5780fc493dab','6d25ffcd-6ec2-3829-8c95-fa3ddb64a5f8','c4149aba-7ed6-523c-286a-8ccde9a0ede9','e3f4112a-94b2-1ead-1f3a-ac608fea204a','474a18e1-f919-7d67-17f8-04be6e0e284f','4521fe02-581f-6184-39d6-c69ef3dc9526','b19f26b5-ff93-102d-2116-6dcc70837db3');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('4bd516eb-8cbf-5d8d-d391-331c68f16a1d','ead44f77-116b-5f7f-8bea-86f580a530e8','f315c3da-946b-4ca0-7edb-472894284a7d','7cef9092-3fa7-edf7-7498-5780fc493dab','6d25ffcd-6ec2-3829-8c95-fa3ddb64a5f8','c4149aba-7ed6-523c-286a-8ccde9a0ede9','e3f4112a-94b2-1ead-1f3a-ac608fea204a','474a18e1-f919-7d67-17f8-04be6e0e284f','4521fe02-581f-6184-39d6-c69ef3dc9526','b19f26b5-ff93-102d-2116-6dcc70837db3')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1='11:30',pauseend1='12:15',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='8ed915d8-32a5-7e02-c8c5-5567af8b8ec7';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-03') and id not in ('995c3aca-6068-3bad-4d4b-53ca54304dee');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:30',timestart2=null,timeend2=null,pausestart1='11:30',pauseend1='12:15',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='09239728-30b0-9a1e-f0d5-44f2799cd539';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-04') and id not in ('481c4e96-0cbb-db56-87f9-c9883ec5c425');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:30:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='11:30:00', pauseend1='12:15:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='f216ecb3-4a77-66e1-c16a-37868d3395ce';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-11') and id not in ('9e5bd644-2867-bc2c-4672-67e59482e192');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('9a660396-b21e-e809-5f68-10fd7d0075df','3f9ba3ab-0694-d025-5e9c-9dc4a6914caa','1ad3ae56-459b-0fc7-89f3-41e61532f3bd','ac7083e4-19c5-d224-47f0-399b557b2792','3a74db40-6a2d-5efb-c3be-1ca21e25979f','f806b869-9ae6-6b70-fe9b-345ddff90a44');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('9a660396-b21e-e809-5f68-10fd7d0075df','3f9ba3ab-0694-d025-5e9c-9dc4a6914caa','1ad3ae56-459b-0fc7-89f3-41e61532f3bd','ac7083e4-19c5-d224-47f0-399b557b2792','3a74db40-6a2d-5efb-c3be-1ca21e25979f','f806b869-9ae6-6b70-fe9b-345ddff90a44')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='18:45',timestart2=null,timeend2=null,pausestart1='13:00',pauseend1='13:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='106f81fb-df7e-41dd-6107-44043886d600';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-18') and id not in ('82064209-dded-589c-4426-69cde5859a80');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='46e7c116-d7d4-d824-68f8-47ef6cfac410';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-25') and id not in ('ed79b0e6-0f25-3c44-9395-d23a6874ce69');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='46e7c116-d7d4-d824-68f8-47ef6cfac410';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-25') and id not in ('ed79b0e6-0f25-3c44-9395-d23a6874ce69');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1='17:00',pauseend1='17:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='a43190ec-87cc-e088-01dd-bab78db42043';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-02-04') and id not in ('');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1='11:15',pauseend1='12:00',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='e813646e-0918-c64f-6c0d-fd870020db65';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-03') and id not in ('95f4dea7-85de-08fe-8d4a-f27b2d4497c0');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('e813646e-0918-c64f-6c0d-fd870020db65');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('e813646e-0918-c64f-6c0d-fd870020db65')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause='01:00:00', pausestart1='14:00:00', pauseend1='14:30:00', pausestart2='18:30:00', pauseend2='19:00:00', vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8475980f-e1ca-1605-dc07-5eb6696f1ffd','965dec45-c4e4-39c3-dd92-6b6cb1a72f6f','31f9ac33-74eb-66ba-8fa8-d6dce320cd7a','61048838-8258-1137-2135-746dc1bdb0f1','472e8269-88ec-ac5e-dc7e-f0f0a190bb70','b79dd423-dbb5-1919-3c63-149dcc7b70e9','927497d2-c268-e4f7-bddc-19a42e430e20','c690c0f3-8685-9675-6ab3-8f2140054d7a','f86ce384-5a91-8d65-47f6-ce58426a3afb','8325f6e3-3f60-4b57-f945-4e8f28c797d7','31c222c6-917f-eeab-38e0-94b2dd5354b7','b4d41750-f216-d38c-9d83-10f34ee4ae97');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('8475980f-e1ca-1605-dc07-5eb6696f1ffd','965dec45-c4e4-39c3-dd92-6b6cb1a72f6f','31f9ac33-74eb-66ba-8fa8-d6dce320cd7a','61048838-8258-1137-2135-746dc1bdb0f1','472e8269-88ec-ac5e-dc7e-f0f0a190bb70','b79dd423-dbb5-1919-3c63-149dcc7b70e9','927497d2-c268-e4f7-bddc-19a42e430e20','c690c0f3-8685-9675-6ab3-8f2140054d7a','f86ce384-5a91-8d65-47f6-ce58426a3afb','8325f6e3-3f60-4b57-f945-4e8f28c797d7','31c222c6-917f-eeab-38e0-94b2dd5354b7','b4d41750-f216-d38c-9d83-10f34ee4ae97')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='18:45',timestart2=null,timeend2=null,pausestart1='15:00',pauseend1='15:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='5e354027-a6c8-3164-812a-df798794655e';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-05') and id not in ('f4abee17-6eb7-ccc8-f080-206e42bef506');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='21bf469a-05db-1574-9747-cfece644be53';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-07') and id not in ('67f24c35-57fa-8778-b9a7-cfd393887c47');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('ea7781b9-8eab-9204-8e19-6735f95e0f7f');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('ea7781b9-8eab-9204-8e19-6735f95e0f7f')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('c724d7e5-cea8-c118-bb62-af9985cd8736','cf7d1836-55fc-7ebd-7b0a-dc835dff9ad3');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('c724d7e5-cea8-c118-bb62-af9985cd8736','cf7d1836-55fc-7ebd-7b0a-dc835dff9ad3')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='5f0e4f42-ef1a-730c-be17-4bc6457ca614';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-20') and id not in ('f6e56b7f-c143-d14b-b7cb-6d24c36c81e0');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('91b52e98-259a-8a49-9c5c-4b47fa52cd53');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('91b52e98-259a-8a49-9c5c-4b47fa52cd53')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1='16:00',pauseend1='16:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='a2923ddb-89a7-d52d-bad0-9b594b2bc352';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-22') and id not in ('d7b714f7-11c9-61eb-474e-8825c176181c');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='5f0e4f42-ef1a-730c-be17-4bc6457ca614';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-20') and id not in ('f6e56b7f-c143-d14b-b7cb-6d24c36c81e0');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('d38fa95d-e8b6-04c6-9091-8e53ac590250');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('d38fa95d-e8b6-04c6-9091-8e53ac590250')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='12:00:00', timeend1='20:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='16:00:00', pauseend1='16:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b47d8524-1ee2-5651-073b-9d23376da041');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('b47d8524-1ee2-5651-073b-9d23376da041')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('3661ef2a-4d38-c10f-b9a8-0f49a9d2fb7b','63394bfc-767a-962f-f95d-f5242a7f4663');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('3661ef2a-4d38-c10f-b9a8-0f49a9d2fb7b','63394bfc-767a-962f-f95d-f5242a7f4663')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('a2923ddb-89a7-d52d-bad0-9b594b2bc352');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('a2923ddb-89a7-d52d-bad0-9b594b2bc352')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1='17:00',pauseend1='17:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='a2923ddb-89a7-d52d-bad0-9b594b2bc352';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-22') and id not in ('d7b714f7-11c9-61eb-474e-8825c176181c');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='12:00:00', timeend1='20:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='17:00:00', pauseend1='17:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('1c2cf2ef-f271-996e-2ce8-72a3538944f1');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('1c2cf2ef-f271-996e-2ce8-72a3538944f1')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:30',timestart2=null,timeend2=null,pausestart1='11:00',pauseend1='11:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='91d20887-1175-22a9-a079-0a78514f4580';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate=date('2022-02-04') and id not in ('');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:30:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='11:00:00', pauseend1='11:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('9a6639be-f4ab-fbd5-69fa-57bc901dce62','4b6ccc2c-e77b-73c1-0217-c3d35545ed87','eddb2037-2b36-3a80-cc56-419b593e8e1d');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('9a6639be-f4ab-fbd5-69fa-57bc901dce62','4b6ccc2c-e77b-73c1-0217-c3d35545ed87','eddb2037-2b36-3a80-cc56-419b593e8e1d')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours='08:00',partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='07889e76-4636-a385-6e5a-6165db1aec00';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate=date('2022-01-31') and id not in ('');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:30:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='11:00:00', pauseend1='11:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b40f1098-ea3b-9143-cd6a-3c3b5f621aad','4ed389d1-77aa-d7d7-bae2-8fc0c87cc78a','52c11a2b-2eba-700b-c463-8fa6ed8e3816','ef475d0b-b1ca-efe1-cab8-c1473303d5c9','48a930d6-08f3-903b-1a0d-9bad35377e1a','0c5b77cb-4680-2b12-85de-00abae349ced','9c2b2f39-65b3-06df-5f63-c49c76f2ec3d','a2e6640b-9aad-7626-d3bf-e4655a39b4bc','01f7c84f-0812-7992-08e6-711ad9e60858','5013386b-34fb-bff2-f299-2ff6882c1ece','b83a6f14-374c-d2dc-5d24-c0192c11b214','a82c0aa3-c869-6271-d8bd-190b3dabcab3');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('b40f1098-ea3b-9143-cd6a-3c3b5f621aad','4ed389d1-77aa-d7d7-bae2-8fc0c87cc78a','52c11a2b-2eba-700b-c463-8fa6ed8e3816','ef475d0b-b1ca-efe1-cab8-c1473303d5c9','48a930d6-08f3-903b-1a0d-9bad35377e1a','0c5b77cb-4680-2b12-85de-00abae349ced','9c2b2f39-65b3-06df-5f63-c49c76f2ec3d','a2e6640b-9aad-7626-d3bf-e4655a39b4bc','01f7c84f-0812-7992-08e6-711ad9e60858','5013386b-34fb-bff2-f299-2ff6882c1ece','b83a6f14-374c-d2dc-5d24-c0192c11b214','a82c0aa3-c869-6271-d8bd-190b3dabcab3')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='05a1be86-a773-3fde-29e2-a32f589405cb';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate=date('2022-01-05') and id not in ('9816f86b-0f7d-1db0-3123-c446bfacc657');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b69c46c0-ab03-8172-83cf-38401a42d77c');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('b69c46c0-ab03-8172-83cf-38401a42d77c')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('be69969d-c4b1-5a4d-03d6-8fcd6fa8d66e','4b0c5619-d9c5-bbd5-47ab-a7a65ff79142','1814c770-cafc-321b-c30d-0873df9b9d7d','cd9d1768-d81a-1368-50cc-100549a394f8','8bcd15b6-b616-3516-2347-cdb972e5985c');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('be69969d-c4b1-5a4d-03d6-8fcd6fa8d66e','4b0c5619-d9c5-bbd5-47ab-a7a65ff79142','1814c770-cafc-321b-c30d-0873df9b9d7d','cd9d1768-d81a-1368-50cc-100549a394f8','8bcd15b6-b616-3516-2347-cdb972e5985c')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='10:00',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours='04:00',partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='6a443826-2784-822e-4fc0-c8982269d19c';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate=date('2022-01-28') and id not in ('');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='cd2d012d-bb1f-7ab1-eed3-49f3f0903df6';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-03') and id not in ('0b7aed2a-2176-2e2c-e3a1-7c9c8cd75108');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('e764c284-aa84-03b4-711a-d34e1513fc45','ed80b3d7-16b0-8fb3-11ac-0d9ff540b402','055227a1-d92d-1384-430e-bb7659bd3b9c','9be55577-1180-d312-6492-4df6b0f3acfe');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('e764c284-aa84-03b4-711a-d34e1513fc45','ed80b3d7-16b0-8fb3-11ac-0d9ff540b402','055227a1-d92d-1384-430e-bb7659bd3b9c','9be55577-1180-d312-6492-4df6b0f3acfe')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:30:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='11:00:00', pauseend1='11:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b88eaeb3-8acf-9651-a795-c5c2b47d992c','12aee72a-dce8-24e4-2213-b0eb6b736808','55cbaa81-c4b1-6fdb-19ae-7e8bcb3d59d1');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('b88eaeb3-8acf-9651-a795-c5c2b47d992c','12aee72a-dce8-24e4-2213-b0eb6b736808','55cbaa81-c4b1-6fdb-19ae-7e8bcb3d59d1')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='879938d8-78f6-bdd7-6a0e-f1d52846bdc1';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-13') and id not in ('38cd262e-5880-109a-24f2-ca7fb7485a9f');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('4b7e70b8-9e3e-23dd-68a6-adb8c682e393');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('4b7e70b8-9e3e-23dd-68a6-adb8c682e393')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='6c6bae67-5f87-d6e8-729a-73bccad69b3c';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-18') and id not in ('b9e6df98-2ee7-d8f9-21b9-58fff4ea80b8');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('d44ff13f-6169-532e-e763-02809b1ca9ef');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('d44ff13f-6169-532e-e763-02809b1ca9ef')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='18:30',timeend1='23:00',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='04:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='beb69515-a737-bf7e-e4a3-dbe21dba7880';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-17') and id not in ('5623fbb3-42d7-7c56-e067-283b28810196');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='11:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='6b050a12-c2a4-53ae-d8e4-b3be3c04d8cd';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-20') and id not in ('63375e10-42dd-0e4b-0e2f-d4e2490eda1e');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1='17:00',pauseend1='17:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='00704bdf-4e0c-3ea4-37e1-61cce6edb680';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-23') and id not in ('adb58475-48bb-df9d-9ed5-63c3c9a86a0d');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('66fa9d2b-6d43-128b-adf6-f8c2971356be','29a7598e-2ebe-6ebb-7c13-02b516efeb55');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('66fa9d2b-6d43-128b-adf6-f8c2971356be','29a7598e-2ebe-6ebb-7c13-02b516efeb55')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='12:00:00', timeend1='20:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='17:00:00', pauseend1='17:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('925790e4-eef1-c9d9-ca0d-7b62347d8a87');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('925790e4-eef1-c9d9-ca0d-7b62347d8a87')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='9744d558-6c12-dab1-b0c0-b0cb48cf4b24';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-27') and id not in ('fb33909b-f72a-a937-6cc8-5fd0ea160229');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1='14:00',pauseend1='14:30',pausestart2='18:30',pauseend2='19:00',payedpause=null,timepause='01:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='9744d558-6c12-dab1-b0c0-b0cb48cf4b24';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-27') and id not in ('fb33909b-f72a-a937-6cc8-5fd0ea160229');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='11:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1='14:00',pauseend1='14:30',pausestart2='18:30',pauseend2='19:00',payedpause=null,timepause='01:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='6b050a12-c2a4-53ae-d8e4-b3be3c04d8cd';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-20') and id not in ('63375e10-42dd-0e4b-0e2f-d4e2490eda1e');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='09:00',timeend1='17:45',timestart2=null,timeend2=null,pausestart1='12:00',pauseend1='12:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='342993d5-9326-39e3-a8ba-a97dc4888bbb';
+EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-30') and id not in ('');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('6528d50b-d677-0e6b-3369-284c7a1e8692','969d1451-7d84-0773-35d7-23310d88de3d');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('6528d50b-d677-0e6b-3369-284c7a1e8692','969d1451-7d84-0773-35d7-23310d88de3d')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='12:00:00', timeend1='20:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='17:00:00', pauseend1='17:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('5cdd5992-f1d3-e78d-7f87-86be3ed51e72');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('5cdd5992-f1d3-e78d-7f87-86be3ed51e72')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause='01:00:00', pausestart1='14:00:00', pauseend1='14:30:00', pausestart2='18:30:00', pauseend2='19:00:00', vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('bd07527d-8d59-4548-b7c6-5b9fa18f3139');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('bd07527d-8d59-4548-b7c6-5b9fa18f3139')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays set timestart1='09:00:00', timeend1='17:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='12:00:00', pauseend1='12:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b9cbdfd4-fe93-2293-e6fd-30f69188dafa');
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in ('b9cbdfd4-fe93-2293-e6fd-30f69188dafa')
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+EXEC: update hotelplacedarme.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption,
+ wdcontracthours
+ from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update hotelplacedarme.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from hotelplacedarme.staffreportperioddays pd
+ join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4')
+ where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;