+QUERY: select us.id,cp.schemata from public.users us left join public.companies cp on (us.id_company=cp.id) where lower(us.username)=lower('ksaffran@dks.lu') and us.userpassword = 'a1b496fa520a1c52edd076ca7a59e56667e7ebeb5ba5ba966d2d01628e165359' and us.isblocked is null;
+EXEC: delete from public.sessions where id_user='e9e6880b-75c7-70b5-ce61-49cf6d62630f' and remote_addr='::1' and user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36';
+QUERY: insert into public.sessions (id_user,id,remote_addr,user_agent,sessiondata) VALUES( 'e9e6880b-75c7-70b5-ce61-49cf6d62630f',public.getuuid(), '::1','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36',('{"schemata":"demo"}'::text)::json) returning id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT distinct(us.schema_name),case when cp.company is null then 'schema:' || us.schema_name else company end as company ,
+ us.schema_name AS schemaname,
+ case when datasetname is null then 'schema:' || us.schema_name else datasetname end as datasetname
+ FROM ( select schema_name from information_schema.schemata where schema_owner != 'postgres' and schema_name != 'public') us
+ JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+QUERYARRAY: select ttr.*, st.* ,stg.groupname,'<span style="font-weight: bold;">' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '</span><br/>' || '<span style="color:' || coalesce(st.color,'') || ';font-style: italic;">'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from demo.staff st
+LEFT JOIN demo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='demo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM demo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from demo.staff st
+LEFT JOIN demo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='demo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM demo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by startdate,enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-30') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-30') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-30') between startdate and enddate) or (startdate <= date('2020-06-30') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '2020-06-29' as datebefore,
+ '16:30' as timebefore,
+ '2020-07-01' as dateafter,
+ '10:30' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-30') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-30') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-30') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-30') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-30') between startdate and enddate) or (startdate <= date('2020-06-30') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '2020-06-29' as datebefore,
+ '16:30' as timebefore,
+ '2020-07-01' as dateafter,
+ '10:30' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-30') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-30') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-30') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-30') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM demo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERYARRAY: select ttr.*, st.* ,stg.groupname,'<span style="font-weight: bold;">' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '</span><br/>' || '<span style="color:' || coalesce(st.color,'') || ';font-style: italic;">'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from demo.staff st
+LEFT JOIN demo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='demo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by startdate,enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername
+| COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '</span><br/>' || '<span style="color:' || coalesce(st.color,'') || ';font-style: italic;">'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from demo.staff st
+LEFT JOIN demo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='demo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM demo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by startdate,enddate;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by startdate,enddate;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE demo.staffreportperioddays SET timestart1='09:00',timeend1='17:00',timestart2=null,timeend2=null,pausestart1='11:00',pauseend1='11: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='ddddfe81-02bf-4f72-ecb8-453facbff515';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from demo.staffreportperiod srp
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by rp.startdate,rp.enddate)
+ sper ) prp where id='2583c916-2d07-f42d-9c85-18ee42959317';
+EXEC: update demo.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from demo.staffreportperioddays where id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update demo.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from demo.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from demo.staffreportperioddays
+where daydate between date('2020-07-01') and date('2020-08-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from demo.staffreportperiod where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and id_reportperiod in (select id from demo.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')
+ --where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-07-01') and date('2020-08-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update demo.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2020-08-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from demo.staffreportperioddays pd
+ join demo.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2583c916-2d07-f42d-9c85-18ee42959317')
+ where pd.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and pd.daydate between date('2020-07-01') and date('2020-08-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE demo.staffreportperioddays SET timestart1='09:00',timeend1='17:00',timestart2=null,timeend2=null,pausestart1='11:00',pauseend1='11: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='ddddfe81-02bf-4f72-ecb8-453facbff515';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from demo.staffreportperiod srp
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by rp.startdate,rp.enddate)
+ sper ) prp where id='2583c916-2d07-f42d-9c85-18ee42959317';
+EXEC: update demo.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from demo.staffreportperioddays where id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update demo.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from demo.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from demo.staffreportperioddays
+where daydate between date('2020-07-01') and date('2020-08-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from demo.staffreportperiod where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and id_reportperiod in (select id from demo.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')
+ --where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-07-01') and date('2020-08-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update demo.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2020-08-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from demo.staffreportperioddays pd
+ join demo.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2583c916-2d07-f42d-9c85-18ee42959317')
+ where pd.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and pd.daydate between date('2020-07-01') and date('2020-08-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+QUERYARRAY: select ttr.*, st.* ,stg.groupname,'<span style="font-weight: bold;">' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '</span><br/>' || '<span style="color:' || coalesce(st.color,'') || ';font-style: italic;">'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from demo.staff st
+LEFT JOIN demo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='demo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM demo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE demo.staffreportperioddays SET timestart1='09:00',timeend1='17:00',timestart2=null,timeend2=null,pausestart1='11:00',pauseend1='11: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='ddddfe81-02bf-4f72-ecb8-453facbff515';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from demo.staffreportperiod srp
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by rp.startdate,rp.enddate)
+ sper ) prp where id='2583c916-2d07-f42d-9c85-18ee42959317';
+EXEC: update demo.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from demo.staffreportperioddays where id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update demo.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from demo.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from demo.staffreportperioddays
+where daydate between date('2020-07-01') and date('2020-08-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from demo.staffreportperiod where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and id_reportperiod in (select id from demo.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')
+ --where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-07-01') and date('2020-08-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update demo.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2020-08-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from demo.staffreportperioddays pd
+ join demo.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2583c916-2d07-f42d-9c85-18ee42959317')
+ where pd.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and pd.daydate between date('2020-07-01') and date('2020-08-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername
+QUERYARRAY: select ttr.*, st.* ,stg.groupname,'<span style="font-weight: bold;">' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '</span><br/>' || '<span style="color:' || coalesce(st.color,'') || ';font-style: italic;">'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from demo.staff st
+LEFT JOIN demo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='demo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM demo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM demo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERYARRAY: select ttr.*, st.* ,stg.groupname,'<span style="font-weight: bold;">' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '</span><br/>' || '<span style="color:' || coalesce(st.color,'') || ';font-style: italic;">'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from demo.staff st
+LEFT JOIN demo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='demo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by startdate,enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE demo.staffreportperioddays SET timestart1='09:00',timeend1='16:00',timestart2=null,timeend2=null,pausestart1='11:00',pauseend1='11: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='ddddfe81-02bf-4f72-ecb8-453facbff515';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from demo.staffreportperiod srp
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by rp.startdate,rp.enddate)
+ sper ) prp where id='2583c916-2d07-f42d-9c85-18ee42959317';
+EXEC: update demo.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from demo.staffreportperioddays where id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update demo.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from demo.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from demo.staffreportperioddays
+where daydate between date('2020-07-01') and date('2020-08-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from demo.staffreportperiod where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and id_reportperiod in (select id from demo.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')
+ --where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-07-01') and date('2020-08-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update demo.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2020-08-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from demo.staffreportperioddays pd
+ join demo.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2583c916-2d07-f42d-9c85-18ee42959317')
+ where pd.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and pd.daydate between date('2020-07-01') and date('2020-08-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+QUERYARRAY: select ttr.*, st.* ,stg.groupname,'<span style="font-weight: bold;">' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '</span><br/>' || '<span style="color:' || coalesce(st.color,'') || ';font-style: italic;">'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from demo.staff st
+LEFT JOIN demo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='demo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM demo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by startdate,enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate < date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE demo.staffreportperioddays SET timestart1='09:00',timeend1='16:00',timestart2=null,timeend2=null,pausestart1='11:00',pauseend1='11: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='ddddfe81-02bf-4f72-ecb8-453facbff515';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from demo.staffreportperiod srp
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by rp.startdate,rp.enddate)
+ sper ) prp where id='2583c916-2d07-f42d-9c85-18ee42959317';
+EXEC: update demo.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from demo.staffreportperioddays where id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update demo.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from demo.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from demo.staffreportperioddays where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from demo.staffreportperioddays
+where daydate between date('2020-07-01') and date('2020-08-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from demo.staffreportperiod where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and id_reportperiod in (select id from demo.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')
+ --where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-07-01') and date('2020-08-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update demo.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2020-08-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from demo.staffreportperioddays pd
+ join demo.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2583c916-2d07-f42d-9c85-18ee42959317')
+ where pd.id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and pd.daydate between date('2020-07-01') and date('2020-08-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from demo.reportperiod where id='2583c916-2d07-f42d-9c85-18ee42959317'
+-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from demo.staffreportperioddays where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate > date('2020-06-29') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2020-07-01') and date('2020-08-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from demo.staffreportperioddays
+ where id_staff= '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2020-06-29') then startdate else date('2020-06-29') end as staffperiodstart,
+ case when enddate is null or enddate > date('2020-09-06') then date('2020-09-06')
+ else enddate end as staffperiodend from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ and startdate < date('2020-09-06')
+ ) sc
+ join demo.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from demo.staffreportperioddays lpd
+ left join demo.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from demo.worktimes where isdefault=true) wkdef
+ where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and lpd.daydate between date('2020-06-29') and date('2020-09-06')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from demo.timetracker
+where daydate between date('2020-07-01') and date('2020-08-31') and id_staff ='5d606bb6-4c9c-24ea-20da-d8f2da9eb597') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select weekhours from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and ((date('2020-06-29') between startdate and enddate) or (startdate <= date('2020-06-29') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(case when maxdayhours > '12:30:00'::interval then '12:30:00'::interval else maxdayhours end ,'HH24:MI') as maxdayhours,
+ to_char('12:30:00'::interval * (1+maxhourspercents),'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char('12:30:00'::interval,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2020-06-30' as dateafter,
+ '11:00' as timeafter
+ from demo.worktimes wk where maxhourspercents is not null and maxdayhours <= '12:30:00' LIMIT 1
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM demo.staffreportperioddays pd
+ JOIN demo.staff st ON pd.id_staff = st.id and st.id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM demo.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join demo.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from demo.worktimes where isdefault =true) wkstd
+ left join demo.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from demo.timetracker where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' and daydate between date('2020-06-29') and date('2020-09-06') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2020-06-29') and date('2020-09-06')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from demo.timetracker where daydate=date('2020-06-29') and id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, '5d606bb6-4c9c-24ea-20da-d8f2da9eb597' as id_staff,date('2020-06-29') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername
+QUERYARRAY: select ttr.*, st.* ,stg.groupname,'<span style="font-weight: bold;">' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '</span><br/>' || '<span style="color:' || coalesce(st.color,'') || ';font-style: italic;">'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from demo.staff st
+LEFT JOIN demo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='demo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM demo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from demo.staff where id='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from demo.staffcontract where id_staff='5d606bb6-4c9c-24ea-20da-d8f2da9eb597' 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= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from demo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from demo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join demo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join demo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join demo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM demo.staffreportperiod srp
+ LEFT JOIN demo.staff st ON srp.id_staff = st.id
+ LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '5d606bb6-4c9c-24ea-20da-d8f2da9eb597'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
+QUERYARRAY: SELECT distinct(us.schema_name),case when cp.company is null then 'schema:' || us.schema_name else company end as company ,
+ us.schema_name AS schemaname,
+ case when datasetname is null then 'schema:' || us.schema_name else datasetname end as datasetname
+ FROM ( select schema_name from information_schema.schemata where schema_owner != 'postgres' and schema_name != 'public') us
+ JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select sessiondata from public.sessions where id='076166fe-8ad4-2888-5824-f4809df3b810'
+EXEC: update public.sessions set sessiondata='{"schemata":"davincenzo"}' where id='076166fe-8ad4-2888-5824-f4809df3b810'
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
+QUERYARRAY: SELECT distinct(us.schema_name),case when cp.company is null then 'schema:' || us.schema_name else company end as company ,
+ us.schema_name AS schemaname,
+ case when datasetname is null then 'schema:' || us.schema_name else datasetname end as datasetname
+ FROM ( select schema_name from information_schema.schemata where schema_owner != 'postgres' and schema_name != 'public') us
+ JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM davincenzo.staffgroups sg LEFT JOIN davincenzo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM davincenzo.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERYARRAY: select id,trackername from davincenzo.timetrackerconfig order by trackername
+QUERYARRAY: select ttr.*, st.* ,stg.groupname,'<span style="font-weight: bold;">' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '</span><br/>' || '<span style="color:' || coalesce(st.color,'') || ';font-style: italic;">'|| coalesce(st.job,'') || '</span>' AS staffname,sc.staffstatus from davincenzo.staff st
+LEFT JOIN davincenzo.staffgroups stg ON st.id_staffgroup = stg.id
+left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current'
+ when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from davincenzo.staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff)
+cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='davincenzo') ttr
+where st.isdeleted is null order by groupname,st.staffnumber,surname,prename;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' and isdeleted is null;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM davincenzo.staffreportperiod srp
+ LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id
+ LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from davincenzo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join davincenzo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname,
+ -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal,
+ mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill,
+ to_char(sum(vacextrahours),'HH24:MI') as totalextra,
+ to_char(sum(vacancyhours),'HH24:MI') as totalvac from (
+ select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname,
+ coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal,
+ spd.vacancyhours,spd.vacillhours,spd.vacextrahours,
+ spd.vacancycomment, spd.vacillcomment, spd.vacextracomment,
+ case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes,
+ coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment,
+ to_char(spd.daydate,'DD') as mday,
+ to_char(spd.daydate,'MM') as mmonth,
+ to_char(spd.daydate,'YYYY') as myear
+ from davincenzo.staffreportperioddays spd
+ join davincenzo.staff st on (st.id=spd.id_staff)
+ join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id)
+ where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3'
+ ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth
+QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM davincenzo.staffreportperiod srp
+ LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id
+ LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname,
+ srp.id as id_staffreportperiod,
+ pd.id_staff,
+ psplit.id_reportperiod as id_reportperiod,
+ min(daydate) as startdate,
+ max(daydate) as enddate,
+ to_char(min(daydate),'YYYY/MM') as ymonth,
+ coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff,
+ coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours,
+ coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours,
+ to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours,
+ to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal,
+ to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill,
+ to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra,
+ to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours,
+ to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours,
+ to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,
+ to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours,
+ sgr.groupname
+ from davincenzo.staffreportperioddays pd
+ join (
+ select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from (
+ select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx
+ ) gp
+ ) psplit on (pd.daydate between psplit.startdate and psplit.enddate)
+ join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod)
+ join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod)
+ join davincenzo.staff st on (pd.id_staff=st.id)
+ LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3'
+ group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname
+ ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT distinct(us.schema_name),case when cp.company is null then 'schema:' || us.schema_name else company end as company ,
+ us.schema_name AS schemaname,
+ case when datasetname is null then 'schema:' || us.schema_name else datasetname end as datasetname
+ FROM ( select schema_name from information_schema.schemata where schema_owner != 'postgres' and schema_name != 'public') us
+ JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM 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;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM davincenzo.staffreportperiod srp
+ LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id
+ LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '06b40eee-f644-be05-3d93-05c235070691'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT distinct(us.schema_name),case when cp.company is null then 'schema:' || us.schema_name else company end as company ,
+ us.schema_name AS schemaname,
+ case when datasetname is null then 'schema:' || us.schema_name else datasetname end as datasetname
+ FROM ( select schema_name from information_schema.schemata where schema_owner != 'postgres' and schema_name != 'public') us
+ JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app';
+QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select sessiondata from public.sessions where id='076166fe-8ad4-2888-5824-f4809df3b810'
+EXEC: update public.sessions set sessiondata='{"schemata":"lousdiner"}' where id='076166fe-8ad4-2888-5824-f4809df3b810'
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT distinct(us.schema_name),case when cp.company is null then 'schema:' || us.schema_name else company end as company ,
+ us.schema_name AS schemaname,
+ case when datasetname is null then 'schema:' || us.schema_name else datasetname end as datasetname
+ FROM ( select schema_name from information_schema.schemata where schema_owner != 'postgres' and schema_name != 'public') us
+ JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app';
+QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM lousdiner.reportperiod rp ORDER BY startdate, enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM lousdiner.reportperiod rp ORDER BY startdate, enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:31',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM lousdiner.reportperiod rp ORDER BY startdate, enddate;
+_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:31',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM lousdiner.reportperiod rp ORDER BY startdate, enddate;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:31',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM lousdiner.reportperiod rp ORDER BY startdate, enddate;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+dhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM lousdiner.reportperiod rp ORDER BY startdate, enddate;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM lousdiner.reportperiod rp ORDER BY startdate, enddate;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:31',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM lousdiner.reportperiod rp ORDER BY startdate, enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-03') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-03') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-03') between startdate and enddate) or (startdate <= date('2021-02-03') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '2021-02-02' as datebefore,
+ '21:30' as timebefore,
+ '2021-02-04' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-03') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-03') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-03') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-03') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-03') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl, to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM lousdiner.reportperiod rp ORDER BY startdate, enddate;
+QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays,
+ coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail
+ FROM lousdiner.workplans wp
+ ORDER BY wp.isdefault, wp.workplan;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:31',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1;
+QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1;
+QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1;
+QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours,
+ to_char(wk.maxweekhours,'HH24:MI') as maxweekhours,
+ to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours,
+ to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation,
+ to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours,
+ '' as datebefore,
+ '' as timebefore,
+ '2021-02-03' as dateafter,
+ '13:00' as timeafter
+ from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null
+ order by wk.startdate,wk.enddate nulls last limit 1;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out,
+case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total
+from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out;
+QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='c1573abe-fcf1-7685-f4c1-56901afaf998';
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+EXEC: DELETE FROM lousdiner.timetracker WHERE id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate=date('2021-02-02') and id not in ('');
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'
+QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff
+ ,to_char(ws.workhours::interval,'HH24:MI') as workhours
+ ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal
+ ,to_char(ws.vacillhours,'HH24:MI') as vacancyill
+ ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra
+ ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours
+ ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours
+ ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours
+ ,to_char(ws.totalhours,'HH24:MI') as totalhours
+ ,cd.contractworkdays
+ ,cd.cmpcontractdays
+ ,cd.cmpweekhours
+ ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours
+ ,ws.periodworkhours
+ ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff
+ ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours
+ ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours
+ ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then
+ to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI')
+ else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI')
+ end as maxweekhours
+ ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else
+ to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI')
+ end as defaultweekhours
+ from (
+ SELECT weekstart,weekend,calweek,calyear, id_staff,
+ sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours,
+ sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours,
+ --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause,
+ sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours,
+ sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours,
+ sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours,
+ sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours,
+ sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours,
+ sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours,
+ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours,
+ sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays,
+ sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01')
+ ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff
+ ORDER BY weekstart) ws left join (
+ select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours,
+ case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays,
+ case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays
+ from ( select id_staff,weekdays ,weekhours,
+ case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart,
+ case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01')
+ else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'
+ and startdate < date('2021-08-01')
+ ) sc
+ join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend)
+ group by date(date_trunc('week',pd.daydate)),pd.id_staff
+ ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart
+ left join (
+ select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from (
+ select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate,
+ case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours ,
+ case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours
+ from lousdiner.staffreportperioddays lpd
+ left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate)
+ cross join (select * from lousdiner.worktimes where isdefault=true) wkdef
+ where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01')
+ order by lpd.daydate ) mh group by id_staff,weekstart
+ ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart
+ left join (
+ select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from (
+ select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from (
+select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker
+where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff
+ ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff;
+QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from (
+ select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp
+ join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod)
+ where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate)
+ sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7';
+EXEC: update lousdiner.staffreportperioddays spds set
+ workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end,
+ dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption ,
+ contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours::interval > '00:00:00'::interval then ds.wdcontracthours else null end
+ from (
+ select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup,
+ case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours,
+ case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours,
+ case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours,
+ case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours,
+ case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours,
+ preds.interruption,
+ (preds.dt1+preds.dt2)-(preds.pdt1+preds.pdt2) as worktime,
+ (preds.pdt1+preds.pdt2) as timepause,
+ wdcontracthours
+ from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours,
+ case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval end else '00:00:00'::interval end as dt1,
+ case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2::interval - timestart2::interval else timeend2::interval - timestart2::interval end else '00:00:00'::interval end as dt2,
+ case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval end else '00:00:00'::interval end as pdt1,
+ case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval end else '00:00:00'::interval end as pdt2,
+ case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then
+ timestart2::interval - timeend1::interval
+ else null end as interruption,
+ wdcontracthours
+ from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) preds) ds where spds.id=ds.id;
+EXEC: update lousdiner.staffreportperioddays spds set
+ nighthours=nh from (
+ select id,daydate,timestart1,timeend1, timestart2,timeend2,
+ coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) -
+ (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval)
+ + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) -
+ (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh
+ from lousdiner.staffreportperioddays s where
+ (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59'
+ or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59')
+ and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days'))
+ ) ds
+ where spds.id=ds.id;
+QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from (
+select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from (
+select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays
+where daydate between date('2021-02-01') and date('2021-07-31')
+and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time
+and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate
+) xsunday) sunresult;
+QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01')));
+QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se
+ join users us on (us.id=se.id_user)
+ left join usergroups ugrp on (ugrp.id=us.id_usergroup)
+ where se.id= '076166fe-8ad4-2888-5824-f4809df3b810' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36' and
+ us.isblocked is null group by se.id,us.id,ugrp.id;
+QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from (
+select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from (
+select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from (
+ SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate,
+ case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day')
+ and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart
+ ) aa group by aa.weekstart order by weekstart
+ ) bb)cc;
+QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment,
+ vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment,
+ date(date_trunc('week',pd.daydate)) as weekstart,
+ to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1,
+ to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1,
+ to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2,
+ to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2,
+ to_char(pd.timepause::interval, 'HH24:MI') AS timepause,
+ -- coalesce('<div class="dspvacancynormal">' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyill">' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '</div>','') ||
+ -- coalesce('<div class="dspvacancyextra">' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '</div>','') AS dspvacancyhours,
+ to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours,
+ to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours,
+ to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours,
+ to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours,
+ to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours,
+ to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours,
+ to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours,
+ to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours,
+ to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours,
+ to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours,
+ to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours,
+ to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1,
+ to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1,
+ to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2,
+ to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2,
+ COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata,
+ COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '<br/>' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata,
+ CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter,
+ to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours,
+ to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours,
+ to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation,
+ to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours,
+ max(vd.vacancyname) as vacancyname,
+ to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime,
+ interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff,
+ max(tt.incompletetrack) as incompletetrack
+ FROM lousdiner.staffreportperioddays pd
+ JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null
+ LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto,
+ yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval,
+ date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours
+ FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate,
+ lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend,
+ xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend
+ FROM ( SELECT sr.id_staff, sr.daydate,
+ CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart,
+ CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend
+ FROM lousdiner.staffreportperioddays sr
+ WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone
+ ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate
+ left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate
+ cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd
+ left join lousdiner.vacancydays vd on pd.daydate=vd.daydate
+ left join (
+ select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime,
+ sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack
+from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate
+ ) tt on pd.daydate=tt.daydate
+ WHERE pd.daydate between date('2021-02-01') and date('2021-08-01')
+ group by pd.id
+ ORDER BY pd.id_staff, pd.daydate;
+QUERY: select weekstart,id_staff,avgtotalhours from (
+ select ws.weekstart, ws.id_staff,
+ AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours
+ from (
+ SELECT weekstart, id_staff,
+sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours
+ FROM (select *,date(date_trunc('week', daydate)) AS weekstart,
+ date(date_trunc('week', daydate) + interval '6 days') AS weekend,
+ date_part('week', daydate) AS calweek,
+ date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays
+ where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')
+ --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31')
+ ) srpd GROUP BY srpd.weekstart,srpd.id_staff
+ ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;
+EXEC: update lousdiner.staffreportperiod rpd set
+ --contracthours=csp.contracthours,
+ workhours=csp.workhours,
+ vacancyill=csp.vacillhours,
+ vacancynormal=csp.vacancynormal,
+ vacancyextra=csp.vacextrahours,
+ otherpaidhours=csp.otherpaidhours,
+ partunemplhours=csp.partunemplhours,
+ totalhours=csp.totalhours,
+ nighthours=csp.nighthours,
+ recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours
+ FROM (
+ select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from (
+ select dp.id,
+ sum(pd.workhours) as workhours,
+ sum(pd.dayhours) as totalhours,
+ sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours,
+ sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal,
+ sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours,
+ sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours,
+ sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours,
+ sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours,
+ sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours,
+ coalesce(dp.contracthours,'00:00:00'::interval) as contracthours,
+ coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0,
+ coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40,
+ coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours
+ from lousdiner.staffreportperioddays pd
+ join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7')
+ where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31')
+ group by dp.id,dp.payedhours,dp.transferedhourscalc
+ ) rp) csp where csp.id=rpd.id;
+QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name,
+ to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours,
+ to_char(srp.workhours, 'HH24:MI'::text) AS workhours,
+ --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours,
+ to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill,
+ to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal,
+ to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra,
+ to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours,
+ to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours,
+ to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours,
+ to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours,
+ case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff,
+ to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours,
+ srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate,
+ COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname,
+ st.id_staffgroup, sgr.groupname,
+ case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours,
+ case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork,
+ case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours
+ ,itmcontracthours,maxdays,srp.isvalidated,
+ to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours,
+ to_char(payedhours0, 'HH24:MI'::text) as payedhours0,
+ to_char(payedhours40, 'HH24:MI'::text) as payedhours40,
+ to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc,
+ to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer,
+ to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc,
+ to_char(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer,
+ to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc,
+ to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours
+ FROM lousdiner.staffreportperiod srp
+ LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id
+ LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id
+ LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id
+ WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f'
+ ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;