Database SQL Operation: OrganisationUnit.searchOrgUnitAssignedTasksByUserDueInTheNextTimePeriod
Description: | Returns a list of the names and full names for all of the users in the specified organization unit plus a count of the tasks assigned to those users. If the user has no task assigned to them, then a count of zero is returned. |
Sterotype: | nsmulti |
SELECT
count(w.taskID) as count,
u.userName,
u.fullName
INTO
:taskAssignedCount,
:taskUserAssignmentUserName,
:taskUserAssignmentFullName
FROM
(
SELECT
DISTINCT Users.userName,
Users.fullName
FROM
Users,
PositionHolderLink,
Position,
OrgUnitPositionLink
WHERE Users.userName = PositionHolderLink.userName
AND PositionHolderLink.positionID = Position.positionID
AND Position.recordStatus = :positionRecordStatus
AND Position.fromDate <= :currentDate
AND
(
Position.toDate >= :currentDate
OR Position.toDate IS NULL
)
AND PositionHolderLink.organisationStructureID = :organizationStructureID
AND OrgUnitPositionLink.positionID = Position.positionID
AND OrgUnitPositionLink.organisationUnitID = :organizationUnitID
AND OrgUnitPositionLink.recordStatus = :orgUnitPositionLinkRecordStatus
AND PositionHolderLink.recordStatus = :positionHolderLinkRecordStatus
AND PositionHolderLink.fromDate <= :currentDate
AND
(
PositionHolderLink.toDate >= :currentDate
OR PositionHolderLink.toDate IS NULL
)
AND Users.statusCode = :userRecordStatus
) u
LEFT OUTER JOIN
TaskAssignment ta
ON ta.relatedName = u.userName
AND ta.assigneeType = 'RL9'
LEFT OUTER JOIN
Task t
ON ta.taskID = t.taskID
AND t.reservedBy is null
LEFT OUTER JOIN
WorkflowDeadline w
ON t.taskID = w.taskID
AND w.deadlineTime >= :fromDeadlineDateTime
AND w.deadlineTime < :toDeadlineDateTime
GROUP
BY u.userName,
u.fullName
ORDER BY userName ASC
|