diff --git a/src/controllers/DevelopmentRequestController.ts b/src/controllers/DevelopmentRequestController.ts index d895f1b8..b917c20b 100644 --- a/src/controllers/DevelopmentRequestController.ts +++ b/src/controllers/DevelopmentRequestController.ts @@ -163,6 +163,13 @@ export class DevelopmentRequestController extends Controller { { keyword: `%${keyword}%`, }, + ).orWhere( + keyword != null && keyword != "" + ? "developmentRequest.createdFullName LIKE :keyword" + : "1=1", + { + keyword: `%${keyword}%`, + }, ); }), ) diff --git a/src/controllers/ProfileEditController.ts b/src/controllers/ProfileEditController.ts index c322d09d..b8cec66d 100644 --- a/src/controllers/ProfileEditController.ts +++ b/src/controllers/ProfileEditController.ts @@ -60,6 +60,11 @@ export class ProfileEditController extends Controller { { keyword: `%${keyword}%`, }, + ).orWhere( + keyword != "" && keyword != null ? "ProfileEdit.remark LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, ); }), ) @@ -114,6 +119,17 @@ export class ProfileEditController extends Controller { { keyword: `%${keyword}%`, }, + ).orWhere( + keyword != "" && keyword != null ? "ProfileEdit.remark LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, + ).orWhere( + keyword != "" && keyword != null ? + "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, ); }), ) diff --git a/src/controllers/ProfileEditEmployeeController.ts b/src/controllers/ProfileEditEmployeeController.ts index ea82ecc4..64fd1421 100644 --- a/src/controllers/ProfileEditEmployeeController.ts +++ b/src/controllers/ProfileEditEmployeeController.ts @@ -65,6 +65,11 @@ export class ProfileEditEmployeeController extends Controller { { keyword: `%${keyword}%`, }, + ).orWhere( + keyword != "" && keyword != null ? "ProfileEdit.remark LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, ); }), ) @@ -119,6 +124,17 @@ export class ProfileEditEmployeeController extends Controller { { keyword: `%${keyword}%`, }, + ).orWhere( + keyword != "" && keyword != null ? "ProfileEdit.remark LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, + ).orWhere( + keyword != "" && keyword != null ? + "CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, ); }), ) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index fbbf38b0..77ca0481 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -907,6 +907,20 @@ export class WorkflowController extends Controller { { keyword: `%${body.keyword}%`, }, + ).orWhere( + body.keyword != null && body.keyword != "" + ? "viewDirectorActing.posNo LIKE :keyword" + : "1=1", + { + keyword: `%${body.keyword}%`, + }, + ).orWhere( + body.keyword != null && body.keyword != "" + ? "viewDirectorActing.posExecutiveName LIKE :keyword" + : "1=1", + { + keyword: `%${body.keyword}%`, + }, ); }), ) @@ -959,6 +973,20 @@ export class WorkflowController extends Controller { { keyword: `%${body.keyword}%`, }, + ).orWhere( + body.keyword != null && body.keyword != "" + ? "viewDirector.posNo LIKE :keyword" + : "1=1", + { + keyword: `%${body.keyword}%`, + }, + ).orWhere( + body.keyword != null && body.keyword != "" + ? "viewDirector.posExecutiveName LIKE :keyword" + : "1=1", + { + keyword: `%${body.keyword}%`, + }, ); }), ) diff --git a/src/interfaces/extension.ts b/src/interfaces/extension.ts index 8a168442..5856f98e 100644 --- a/src/interfaces/extension.ts +++ b/src/interfaces/extension.ts @@ -230,9 +230,7 @@ class Extension { public static ToThaiShortYear(value: Date) { let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear(); - return ( - yy.toString() - ); + return yy.toString(); } public static sumObjectValues(array: any, propertyName: any) { @@ -247,6 +245,9 @@ class Extension { public static CheckCitizen(value: string) { let citizen = value; + if (citizen == null || citizen == "") { + return citizen; + } if (citizen.length !== 13) { throw new HttpError( HttpStatus.NOT_FOUND,