diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 5522f9c..298c8a1 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2952,8 +2952,8 @@ export class DevelopmentController extends Controller { const oldProfile: any = getDevelopment.developmentHistorys.find( (x) => x.citizenId == item["รหัสประจำตัวประชาชน"], ); - if (oldProfile != null) { - if (oldProfile.isDone == true) return; + if (oldProfile.length > 0) { + return; } if (item["ประเภท"] == undefined) return; let development = Object.assign(new DevelopmentHistory(), oldProfile); @@ -3202,30 +3202,28 @@ export class DevelopmentController extends Controller { let status = null; let _null: any = null; if (oldProfile != null) { - if (oldProfile.isDone == true) - throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ข้อมูลนี้ได้ถูกบันทึกแล้ว"); - oldProfile.dateStart = requestBody.dateStart == undefined ? _null : requestBody.dateStart; - oldProfile.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; - oldProfile.order = requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; - oldProfile.dateOrder = - requestBody.commandDate == undefined ? _null : new Date(requestBody.commandDate); - oldProfile.trainingDays = - requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; - oldProfile.createdUserId = request.user.sub; - oldProfile.createdFullName = request.user.name; - oldProfile.lastUpdateUserId = request.user.sub; - oldProfile.lastUpdateFullName = request.user.name; - oldProfile.createdAt = new Date(); - oldProfile.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(oldProfile, { data: request }); - setLogDataDiff(request, { before, after: oldProfile }); - status = oldProfile.isProfile; + throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ข้อมูลนี้ได้ถูกบันทึกแล้ว"); } + oldProfile.dateStart = requestBody.dateStart == undefined ? _null : requestBody.dateStart; + oldProfile.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; + oldProfile.order = requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; + oldProfile.dateOrder = requestBody.commandDate == undefined ? _null : new Date(requestBody.commandDate); + oldProfile.trainingDays = requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; + oldProfile.createdUserId = request.user.sub; + oldProfile.createdFullName = request.user.name; + oldProfile.lastUpdateUserId = request.user.sub; + oldProfile.lastUpdateFullName = request.user.name; + oldProfile.createdAt = new Date(); + oldProfile.lastUpdatedAt = new Date(); + // addLogSequence(request, { + // action: "database", + // status: "success", + // description: "Store DevelopmentHistory.", + // }); + await this.developmentHistoryRepository.save(oldProfile, { data: request }); + setLogDataDiff(request, { before, after: oldProfile }); + status = oldProfile.isProfile; + if (requestBody.type == "OFFICER") { await new CallAPI() diff --git a/src/controllers/DevelopmentEmployeeHistoryController.ts b/src/controllers/DevelopmentEmployeeHistoryController.ts index aeae26e..9fe87ae 100644 --- a/src/controllers/DevelopmentEmployeeHistoryController.ts +++ b/src/controllers/DevelopmentEmployeeHistoryController.ts @@ -260,6 +260,7 @@ export class DevelopmentEmployeeHistoryController extends Controller { .leftJoinAndSelect("developmentHistory.development", "development") .leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel") .leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType") + .where("developmentHistory.isProfile IS TRUE") .andWhere( body.year != 0 && body.year != null && body.year != undefined ? "development.year = :year" diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index fa3c5e9..57ec84c 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -170,6 +170,16 @@ export class DevelopmentScholarshipController extends Controller { _data = x; }) .catch((x) => {}); + + if (keyword && ["กำลังศึกษา", "เรียนไม่จบ", "เรียนจบ"].includes(keyword.trim())) { + const mapStatus: Record = { + "กำลังศึกษา": "PENDING", + "เรียนไม่จบ": "NOTGRADUATE", + "เรียนจบ": "GRADUATE", + }; + keyword = mapStatus[keyword.trim()]; + } + let query = await AppDataSource.getRepository(DevelopmentScholarship) .createQueryBuilder("developmentScholarship") .leftJoinAndSelect("developmentScholarship.posLevel", "posLevel") @@ -196,42 +206,50 @@ export class DevelopmentScholarshipController extends Controller { keyword: `%${keyword}%`, }, ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.citizenId LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.position LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.posExecutive LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1", - { - keyword: `%${keyword}%`, - }, - ); + .orWhere( + keyword != null && keyword != "" + ? "developmentScholarship.citizenId LIKE :keyword" + : "1=1", + { + keyword: `%${keyword}%`, + }, + ) + .orWhere( + keyword != null && keyword != "" + ? "developmentScholarship.position LIKE :keyword" + : "1=1", + { + keyword: `%${keyword}%`, + }, + ) + .orWhere( + keyword != null && keyword != "" + ? "developmentScholarship.posExecutive LIKE :keyword" + : "1=1", + { + keyword: `%${keyword}%`, + }, + ) + .orWhere( + keyword != null && keyword != "" + ? "developmentScholarship.status LIKE :keyword" + : "1=1", + { + keyword: `${keyword}`, + }, + ) + .orWhere( + keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, + ) + .orWhere( + keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, + ); }), ) .andWhere( diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index e6b9826..d6307e1 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -658,13 +658,18 @@ export class ReportController extends Controller { : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.graduatedDate)), graduatedReason: getDevelopment.graduatedReason == null ? "" : getDevelopment.graduatedReason, useOfficialTime: getDevelopment.useOfficialTime, - useOffTime: getDevelopment.useOfficialTime == "NOUSETIME" ? "🗹 ใช้ ☐ ไม่ใช้" : "☐ ใช้ 🗹 ไม่ใช้", + useOffTime: + getDevelopment.useOfficialTime == "NOUSETIME" + ? "☐ ใช้ 🗹 ไม่ใช้ เวลาราชการ" + : getDevelopment.useOfficialTime == "USETIME" + ? "🗹 ใช้ ☐ ไม่ใช้ เวลาราชการ" + : "🗹 ใช้ ☐ ไม่ใช้ เวลาราชการบางส่วน", isGraduated: getDevelopment.isGraduated, isG1: getDevelopment.isGraduated == true ? "🗹" : "☐", isG2: getDevelopment.isGraduated == true ? "☐" : "🗹", totalPeriod: getDevelopment.totalPeriod == null || getDevelopment.totalPeriod == "" - ? "" + ? "-" : Extension.ToThaiNumber(getDevelopment.totalPeriod), };