diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 557d727d..2318da33 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -1132,6 +1132,19 @@ export class ProfileEmployeeTempController extends Controller { child4: _dataOrg.child4, }, ) + // หรือ ไม่ได้เลือกตำแหน่งในโครงสร้างลูกจ้างชั่วคราว แต่เลือกตำแหน่งในโครงสร้างลูกจ้างประจำแล้ว + .orWhere( + `current_holderTemps.orgRootId is null AND + profileEmployee.rootIdTemp is not null AND + profileEmployee.statusTemp = :statusTemp AND + profileEmployee.employeeClass = :type AND + profileEmployee.createdUserId = :keycloak`, + { + statusTemp: "PENDING", + type: "TEMP", + keycloak: request.user.sub + } + ) .getManyAndCount(); const data = await Promise.all( record.map((_data) => {