Hello all,
I have a request to build a process that get all opened timesheets and submit them if the user is unvailable the whole week.
Ive started this query to get the opened timsheets but it gives only the timesheets which the users have populated.
select
res.unique_name [Resource_Id],
res.FULL_NAME [Resource_Name],
slice_date [Week_Start_Date],
CASE WHEN (SUM(slice)/8)=0 THEN 0 ELSE 1 END [Availability],
replace(convert(varchar, PD.PRSTART, 111), '/', '-') AS TP_START,
replace(convert(varchar, PD.PRFINISH, 111), '/', '-') AS TP_FINISH,
pt.prid as ts_id,
pt.prstatus,
pt.prversion,
pd.prid as tp_id
from prj_blb_slices wk
inner join prj_blb_slicerequests req on wk.slice_request_id=req.id and req.request_name = 'WEEKLYRESOURCEAVAILCURVE'
inner join srm_resources res on res.id=wk.prj_object_id
left outer join prtimesheet pt on res.id=pt.PRRESOURCEID
Left outer join PRTIMEPERIOD pd on pt.PRTIMEPERIODID=pd.prid
where res.LAST_NAME='DIOUF'
and wk.SLICE_DATE>=pd.prstart
and pd.prfinish > wk.SLICE_DATE
and (pt.PRSTATUS=0 or pt.PRSTATUS=2)
GROUP BY
res.unique_name,
res.FULL_NAME,
slice_date,
replace(convert(varchar, PD.PRSTART, 111), '/', '-') ,
replace(convert(varchar, PD.PRFINISH, 111), '/', '-'),
pt.prid ,
pt.prstatus,
pt.prversion,
pd.prid
order by
slice_date
Any help to get this or a suggestion of how to query thoses timesheet not populated will be grateful.
thank you,
Karim