diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index cd919c19..96fa3db6 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -4434,6 +4434,7 @@ export class PositionController extends Controller { typeCommand: string | null; posType?: string | null; posLevel?: string | null; + profileId?: string | null; isAll: boolean; isBlank: boolean; }, @@ -4475,9 +4476,13 @@ export class PositionController extends Controller { posLevel: posLevel?.id, }; } else if (body.typeCommand == "APPOINT") { - conditionA = "posType.posTypeRank > :posTypeRank"; + // เดิม : กรองเฉพาะ posTypeRank ที่สูงกว่า + // conditionA = "posType.posTypeRank > :posTypeRank"; + // ใหม่ : กรองเฉพาะ posType ที่สูงหรือต่ำกว่าก็ได้ + conditionA = "positions.posTypeId != :currentPosType"; params = { - posTypeRank: posType?.posTypeRank ?? 0, + // posTypeRank: posType?.posTypeRank ?? 0, + currentPosType: posType?.id, }; } else if (body.typeCommand == "SLIP") { conditionA = "positions.posTypeId LIKE :posType AND posLevel.posLevelRank > :posLevelRank"; @@ -4541,6 +4546,10 @@ export class PositionController extends Controller { typeCondition.current_holderId = IsNull(); } + if (body.typeCommand === "MOVE" && body.profileId && !body.isBlank) { + typeCondition.current_holderId = Not(body.profileId); + } + const [posMaster, total] = await AppDataSource.getRepository(PosMaster) .createQueryBuilder("posMaster") .leftJoinAndSelect("posMaster.orgRevision", "orgRevision")