Operation Details
Description: Returns user job tasks due by week.
Sterotype: nsmulti
SQL
SELECT
  t.taskID,
  t.priority,
  t.reservedBy,
  CASE 
    WHEN e.userName is null 
    THEN u.userName 
    ELSE e.userName 
  END
  ,
  t.assignedDateTime,
  w.deadlineTime,
  t.wdoSnapshot,
  t.overflowInd,
  t.versionNo
INTO
  :taskID,
  :taskPriority,
  :taskReservedByUserName,
  :taskReservedByFullUserName,
  :taskAssignedDateTime,
  :taskDeadlineDateTime,
  :wdoSnapshot,
  :overflowInd,
  :versionNo 
FROM
  Task t 
  
  LEFT OUTER JOIN
  
  Users u 
  ON (t.reservedBy = u.userName) 
  
  LEFT OUTER JOIN
  
  ExternalUser e 
  ON (t.reservedBy = e.userName),
  WorkflowDeadline w 
WHERE t.taskID = w.taskID 
  AND w.deadlineTime >= :fromDeadlineDateTime 
  AND w.deadlineTime < :toDeadlineDateTime 
  AND t.taskID IN 
  ( 
  SELECT
    taskID 
  FROM
    TaskAssignment ta 
  WHERE ta.assigneeType = :assigneeType 
    AND ta.relatedID IN 
    ( 
    SELECT
      DISTINCT j.jobID 
    FROM
      Users u,
      PositionHolderLink ph,
      Position p,
      OrgUnitPositionLink oup ,
      Job j 
    WHERE u.userName = :relatedName 
      AND u.userName = ph.userName 
      AND ph.positionID = p.positionID 
      AND p.positionID = oup.positionID 
      AND j.jobID =p.jobID 
      AND ph.recordStatus = :recordStatus 
      AND :currentDate >= ph.fromDate 
      AND 
      (
        :currentDate <= ph.toDate 
        OR ph.toDate IS NULL 
      ) 
    ) 
    AND 
    (
      :allTasksInd = '0' 
      OR 
      (
        t.reservedBy IS NULL 
        OR t.reservedBy IS NOT NULL 
      ) 
    ) 
    AND 
    (
      :allReservedTasksInd = '0' 
      OR t.reservedBy IS NOT NULL 
    ) 
    AND 
    (
      :allAssignedTasksInd = '0' 
      OR t.reservedBy IS NULL 
    ) 
  ) 
ORDER BY deadlineTime ASC