SELECT
ta.taskID,
t.assignedDateTime,
t.wdoSnapshot,
ou.name,
w.deadlineTime,
t.priority,
t.status,
t.versionNo
INTO
:taskID,
:assignedDateTime,
:subject,
:assignedTo,
:taskDeadlineDateTime,
:taskPriority,
:status,
:versionNo
FROM
TaskAssignment ta,
OrganisationUnit ou,
Task t
LEFT OUTER JOIN
WorkFlowDeadLine w
ON w.taskID = t.taskID
WHERE ta.taskID = t.taskID
AND t.status NOT IN( :taskCompleted, :taskClosed)
AND ta.relatedID = ou.organisationUnitID
AND t.reservedBy IS NULL
AND ta.assigneeType = :assigneeType
AND ta.relatedID IN
(
SELECT
DISTINCT ou.organisationUnitID
FROM
Users u ,
PositionHolderLink ph ,
Position p ,
OrgUnitPositionLink oup ,
OrganisationUnit ou
WHERE u.userName = :relatedName
AND u.userName = ph.userName
AND ph.positionID = p.positionID
AND p.positionID = oup.positionID
AND oup.organisationUnitID = ou.organisationUnitID
AND
(
:searchByRelatedIDInd = '0'
OR ou.organisationUnitID = :relatedID
)
AND ph.recordStatus = :recordStatus
AND :currentDate >= ph.fromDate
AND
(
:currentDate <= ph.toDate
OR ph.toDate IS NULL
)
)
|