diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index ae5c8859..d8aa0b77 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -865,6 +865,7 @@ export class WorkflowController extends Controller { type?: string | null; sortBy?: string | null; descending?: boolean; + isAllDirector?: boolean; }, ) { const userKeycloak = body.keycloakId ?? request.user.sub; @@ -953,38 +954,46 @@ export class WorkflowController extends Controller { let mainConditions: any[] = []; if (type.trim().toUpperCase() === "OPERATE" || body.type === "employee") { - mainConditions = [ - { ...baseCondition, orgRootId: In(roodIds), orgChild1Id: IsNull() }, - { - ...baseCondition, - orgRootId: In(roodIds), - orgChild1Id: posMasterUser.orgChild1Id, - orgChild2Id: IsNull(), - }, - { - ...baseCondition, - orgRootId: In(roodIds), - orgChild1Id: posMasterUser.orgChild1Id, - orgChild2Id: posMasterUser.orgChild2Id, - orgChild3Id: IsNull(), - }, - { - ...baseCondition, - orgRootId: In(roodIds), - orgChild1Id: posMasterUser.orgChild1Id, - orgChild2Id: posMasterUser.orgChild2Id, - orgChild3Id: posMasterUser.orgChild3Id, - orgChild4Id: IsNull(), - }, - { - ...baseCondition, - orgRootId: In(roodIds), - orgChild1Id: posMasterUser.orgChild1Id, - orgChild2Id: posMasterUser.orgChild2Id, - orgChild3Id: posMasterUser.orgChild3Id, - orgChild4Id: posMasterUser.orgChild4Id, - }, - ]; + + if (body.isAllDirector === true) { + mainConditions = [ + { ...baseCondition, orgRootId: In(roodIds) } + ]; + } + else { + mainConditions = [ + { ...baseCondition, orgRootId: In(roodIds), orgChild1Id: IsNull() }, + { + ...baseCondition, + orgRootId: In(roodIds), + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: IsNull(), + }, + { + ...baseCondition, + orgRootId: In(roodIds), + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: posMasterUser.orgChild2Id, + orgChild3Id: IsNull(), + }, + { + ...baseCondition, + orgRootId: In(roodIds), + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: posMasterUser.orgChild2Id, + orgChild3Id: posMasterUser.orgChild3Id, + orgChild4Id: IsNull(), + }, + { + ...baseCondition, + orgRootId: In(roodIds), + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: posMasterUser.orgChild2Id, + orgChild3Id: posMasterUser.orgChild3Id, + orgChild4Id: posMasterUser.orgChild4Id, + }, + ]; + } } else if (isLowLevel) { mainConditions = [ {