diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 3e0d6fe1..ccb231a4 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1385,6 +1385,10 @@ export class ProfileController extends Controller { } }); + if (leaves.length === 0) { + leaves.push({year:""}); + } + const leave2_raw = await this.profileLeaveRepository .createQueryBuilder("profileLeave") .leftJoinAndSelect("profileLeave.leaveType", "leaveType") @@ -1730,16 +1734,6 @@ export class ProfileController extends Controller { }); } } - else { - _assistances.push({ - date: "", - position: "", - commandName: "", - agency: "", - note: "", - document: "", - }); - } // Merge รักษาการ และ ช่วยราชาร const actposition = [..._actpositions, ..._assistances]; diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 559e5b70..89293c5d 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1379,6 +1379,10 @@ export class ProfileEmployeeController extends Controller { } }); + if (leaves.length === 0) { + leaves.push({year:""}); + } + const leave2_raw = await this.profileLeaveRepository .createQueryBuilder("profileLeave") .leftJoinAndSelect("profileLeave.leaveType", "leaveType") @@ -1536,72 +1540,78 @@ export class ProfileEmployeeController extends Controller { }, ]; // ลูกจ้างยังไม่มีรักษาการและช่วยราชการ - const actposition_raw = await this.profileActpositionRepo.find({ - select: ["dateStart", "dateEnd", "position", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, - order: { createdAt: "ASC" }, - }); - const assistance_raw = await this.profileAssistanceRepository.find({ - select: ["dateStart", "dateEnd", "commandName", "agency", "document", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, - order: { createdAt: "ASC" }, - }); + // const actposition_raw = await this.profileActpositionRepo.find({ + // select: ["dateStart", "dateEnd", "position", "isDeleted"], + // where: { profileEmployeeId: id, isDeleted: false }, + // order: { createdAt: "ASC" }, + // }); + // const assistance_raw = await this.profileAssistanceRepository.find({ + // select: ["dateStart", "dateEnd", "commandName", "agency", "document", "isDeleted"], + // where: { profileEmployeeId: id, isDeleted: false }, + // order: { createdAt: "ASC" }, + // }); - const _actposition = - actposition_raw.length > 0 - ? actposition_raw.map((item) => ({ - date: - item.dateStart && item.dateEnd - ? Extension.ToThaiNumber( - `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, - ) - : item.dateStart - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) - : item.dateEnd - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)) - : "", - position: item.position ? Extension.ToThaiNumber(item.position) : "", - commandName: "รักษาการในตำแหน่ง", - agency: "", - document: "", - })) - : [ - { - date: "", - position: "", - commandName: "", - agency: "", - document: "", - }, - ]; - const _assistance = - assistance_raw.length > 0 - ? assistance_raw.map((item) => ({ - date: - item.dateStart && item.dateEnd - ? Extension.ToThaiNumber( - `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, - ) - : item.dateStart - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) - : item.dateEnd - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)) - : "", - position: "", - commandName: item.commandName ? Extension.ToThaiNumber(item.commandName) : "", - agency: item.agency ? Extension.ToThaiNumber(item.agency) : "", - document: item.document ? Extension.ToThaiNumber(item.document) : "", - })) - : [ - { - date: "", - position: "", - commandName: "", - agency: "", - document: "", - }, - ]; - const actposition = [..._actposition, ..._assistance]; + // const _actposition = + // actposition_raw.length > 0 + // ? actposition_raw.map((item) => ({ + // date: + // item.dateStart && item.dateEnd + // ? Extension.ToThaiNumber( + // `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, + // ) + // : item.dateStart + // ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) + // : item.dateEnd + // ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)) + // : "", + // position: item.position ? Extension.ToThaiNumber(item.position) : "", + // commandName: "รักษาการในตำแหน่ง", + // agency: "", + // document: "", + // })) + // : [ + // { + // date: "", + // position: "", + // commandName: "", + // agency: "", + // document: "", + // }, + // ]; + // const _assistance = + // assistance_raw.length > 0 + // ? assistance_raw.map((item) => ({ + // date: + // item.dateStart && item.dateEnd + // ? Extension.ToThaiNumber( + // `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, + // ) + // : item.dateStart + // ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) + // : item.dateEnd + // ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)) + // : "", + // position: "", + // commandName: item.commandName ? Extension.ToThaiNumber(item.commandName) : "", + // agency: item.agency ? Extension.ToThaiNumber(item.agency) : "", + // document: item.document ? Extension.ToThaiNumber(item.document) : "", + // })) + // : [ + // { + // date: "", + // position: "", + // commandName: "", + // agency: "", + // document: "", + // }, + // ]; + const actposition = [{ + date: "", + position: "", + commandName: "", + agency: "", + document: "", + }]; const duty_raw = await this.dutyRepository.find({ where: { profileEmployeeId: id, isDeleted: false }, order: { createdAt: "ASC" }, @@ -1799,7 +1809,7 @@ export class ProfileEmployeeController extends Controller { (_root == null ? "" : _root).trim() const _position = profiles?.position != null ? profiles?.posLevel != null - ? `${profiles.position}${profiles.posLevel.posLevelName}` + ? Extension.ToThaiNumber(`${profiles.position}${profiles.posLevel.posLevelName}`) : profiles.position : "" const ocAssistance = await this.profileAssistanceRepository.findOne({