diff --git a/src/controllers/DevelopmentRequestController.ts b/src/controllers/DevelopmentRequestController.ts index 14c485c4..f629e1d5 100644 --- a/src/controllers/DevelopmentRequestController.ts +++ b/src/controllers/DevelopmentRequestController.ts @@ -369,7 +369,8 @@ export class DevelopmentRequestController extends Controller { posLevelName: profile.posLevel.posLevelName, posTypeName: profile.posType.posTypeName, fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`, - isDeputy: orgRoot?.isDeputy ?? false + isDeputy: orgRoot?.isDeputy ?? false, + orgRootId: orgRoot?.id ?? null }) .catch((error) => { console.error("Error calling API:", error); diff --git a/src/controllers/ProfileEditController.ts b/src/controllers/ProfileEditController.ts index 35f26786..17b952d8 100644 --- a/src/controllers/ProfileEditController.ts +++ b/src/controllers/ProfileEditController.ts @@ -363,7 +363,8 @@ export class ProfileEditController extends Controller { posLevelName: profile.posLevel.posLevelName, posTypeName: profile.posType.posTypeName, fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`, - isDeputy: orgRoot?.isDeputy ?? false + isDeputy: orgRoot?.isDeputy ?? false, + orgRootId: orgRoot?.id ?? null }) .catch((error) => { console.error("Error calling API:", error); diff --git a/src/controllers/ProfileEditEmployeeController.ts b/src/controllers/ProfileEditEmployeeController.ts index 2cdd9fde..288dc724 100644 --- a/src/controllers/ProfileEditEmployeeController.ts +++ b/src/controllers/ProfileEditEmployeeController.ts @@ -363,7 +363,8 @@ export class ProfileEditEmployeeController extends Controller { posLevelName: "EMP", posTypeName: "EMP", fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`, - isDeputy: orgRoot?.isDeputy ?? false + isDeputy: orgRoot?.isDeputy ?? false, + orgRootId: orgRoot?.id ?? null }) .catch((error) => { console.error("Error calling API:", error); diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 8e9d2cd4..0609c932 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -54,6 +54,7 @@ export class WorkflowController extends Controller { posTypeName: string; fullName?: string | null; isDeputy?: boolean | null; + orgRootId?: string | null; }, ) { // ขั้นที่ 1: ทำการค้นหา profile และ metaWorkflow แบบ parallel @@ -203,9 +204,10 @@ export class WorkflowController extends Controller { posMasterAssigns: { assignId: body.sysName }, orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, current_holderId: Not(IsNull()), // เพิ่มเงื่อนไขนี้เพื่อกรองเฉพาะที่มี current_holder + ...(body.orgRootId && { orgRootId: body.orgRootId }), // กรองเฉพาะที่อยู่ในสำนักเดียวกัน (ถ้าส่งมา) }, relations: ["orgChild1"], - select: ["current_holderId", "orgChild1"], // เลือกเฉพาะ field ที่จำเป็น + // select: ["current_holderId", "orgChild1"], // เลือกเฉพาะ field ที่จำเป็น }); // สร้าง StateOperatorUsers สำหรับ officers