From 99e600caacc219b3b8728a51d865ff65e799c449 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 9 Apr 2024 14:32:30 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7?= =?UTF-8?q?=E0=B8=AD=E0=B8=99=E0=B9=83=E0=B8=99report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 581 +++++++++++++++++++++------- 1 file changed, 451 insertions(+), 130 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 34f57132..d978858a 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -175,7 +175,7 @@ export class ReportController extends Controller { posType: posType.join(" หรือ "), posLevel: posLevel.join(" หรือ "), posExecutive: posExecutive.join(" หรือ "), - reason: posMaster.reason, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -188,7 +188,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -218,7 +218,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -278,7 +278,7 @@ export class ReportController extends Controller { posType: posType.join(" หรือ "), posLevel: posLevel.join(" หรือ "), posExecutive: posExecutive.join(" หรือ "), - reason: posMaster.reason, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -291,7 +291,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -323,7 +323,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -383,7 +383,7 @@ export class ReportController extends Controller { positionName: positionName.join(" หรือ "), posType: posType.join(" หรือ "), posLevel: posLevel.join(" หรือ "), - reason: posMaster.reason, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -396,7 +396,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -428,7 +428,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -491,7 +491,7 @@ export class ReportController extends Controller { posType: posType.join(" หรือ "), posLevel: posLevel.join(" หรือ "), posExecutive: posExecutive.join(" หรือ "), - reason: posMaster.reason, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -504,7 +504,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -537,7 +537,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -598,7 +598,7 @@ export class ReportController extends Controller { posType: posType.join(" หรือ "), posLevel: posLevel.join(" หรือ "), posExecutive: posExecutive.join(" หรือ "), - reason: posMaster.reason, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -611,7 +611,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -644,7 +644,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -704,6 +704,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -734,6 +736,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -764,6 +768,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -794,6 +800,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -801,6 +809,7 @@ export class ReportController extends Controller { "posMasters.next_holder.current_holders.orgChild2", "posMasters.next_holder.current_holders.orgChild3", "posMasters.next_holder.current_holders.orgChild4", + "posMasters.next_holder.current_holders.orgChild4", "posMasters.positions", "posMasters.positions.posLevel", "posMasters.positions.posType", @@ -824,6 +833,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -937,6 +948,32 @@ export class ReportController extends Controller { ), ]; } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { posMasterOrder: posMaster.posMasterOrder, // @@ -1057,8 +1094,8 @@ export class ReportController extends Controller { : positionMasterProfileOld.positions.find( (x: any) => x.positionIsSelected == true, )?.posExecutive?.posExecutiveName, - education: "", - salary: "", + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, }; if (_node == null) { const head = { @@ -1078,7 +1115,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -1093,8 +1130,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(_head); } else { @@ -1128,7 +1165,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -1146,8 +1183,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(head); } @@ -1231,6 +1268,32 @@ export class ReportController extends Controller { ), ]; } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { posMasterOrder: posMaster.posMasterOrder, // @@ -1351,8 +1414,8 @@ export class ReportController extends Controller { : positionMasterProfileOld.positions.find( (x: any) => x.positionIsSelected == true, )?.posExecutive?.posExecutiveName, - education: "", - salary: "", + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, }; if (_node == null) { const head = { @@ -1372,7 +1435,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -1387,8 +1450,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(_head); } else { @@ -1424,7 +1487,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -1442,8 +1505,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(head); } @@ -1527,6 +1590,32 @@ export class ReportController extends Controller { ), ]; } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { posMasterOrder: posMaster.posMasterOrder, // @@ -1647,8 +1736,8 @@ export class ReportController extends Controller { : positionMasterProfileOld.positions.find( (x: any) => x.positionIsSelected == true, )?.posExecutive?.posExecutiveName, - education: "", - salary: "", + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, }; if (_node == null) { const head = { @@ -1668,7 +1757,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -1686,8 +1775,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(_head); } else { @@ -1723,7 +1812,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -1745,8 +1834,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(head); } @@ -1832,6 +1921,32 @@ export class ReportController extends Controller { ), ]; } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { posMasterOrder: posMaster.posMasterOrder, // @@ -1952,8 +2067,8 @@ export class ReportController extends Controller { : positionMasterProfileOld.positions.find( (x: any) => x.positionIsSelected == true, )?.posExecutive?.posExecutiveName, - education: "", - salary: "", + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, }; if (_node == null) { const head = { @@ -1973,7 +2088,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -1991,8 +2106,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(_head); } else { @@ -2029,7 +2144,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -2051,8 +2166,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(head); } @@ -2137,6 +2252,32 @@ export class ReportController extends Controller { ), ]; } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { posMasterOrder: posMaster.posMasterOrder, // @@ -2257,8 +2398,8 @@ export class ReportController extends Controller { : positionMasterProfileOld.positions.find( (x: any) => x.positionIsSelected == true, )?.posExecutive?.posExecutiveName, - education: "", - salary: "", + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, }; if (_node == null) { const head = { @@ -2278,7 +2419,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -2296,8 +2437,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(_head); } else { @@ -2334,7 +2475,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -2356,8 +2497,8 @@ export class ReportController extends Controller { profilePositionName: node.profilePositionName, profilePosType: node.profilePosType, profilePosLevel: node.profilePosLevel, - education: "", - salary: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), }; data.push(head); } @@ -2407,6 +2548,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -2437,6 +2580,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -2467,6 +2612,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -2497,6 +2644,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -2527,6 +2676,8 @@ export class ReportController extends Controller { "posMasters.next_holder", "posMasters.next_holder.posLevel", "posMasters.next_holder.posType", + "posMasters.next_holder.profileSalary", + "posMasters.next_holder.profileEducations", "posMasters.next_holder.current_holders", "posMasters.next_holder.current_holders.positions", "posMasters.next_holder.current_holders.orgRoot", @@ -2581,6 +2732,32 @@ export class ReportController extends Controller { (x) => x.orgRevisionId == orgRevisionActive.id, ); } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { orgTreeName: orgRoot.orgRootName, @@ -2616,11 +2793,11 @@ export class ReportController extends Controller { )?.posExecutive?.posExecutiveName, profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", - reason: posMaster.reason, + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, + positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount, + mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -2638,7 +2815,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -2648,10 +2825,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(_head); @@ -2678,7 +2859,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -2688,10 +2869,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(head); @@ -2717,6 +2902,32 @@ export class ReportController extends Controller { (x) => x.orgRevisionId == orgRevisionActive.id, ); } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { orgTreeName: orgChild1.orgChild1Name, @@ -2752,11 +2963,11 @@ export class ReportController extends Controller { )?.posExecutive?.posExecutiveName, profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", - reason: posMaster.reason, + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, + positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount, + mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -2774,7 +2985,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -2784,10 +2995,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(_head); @@ -2816,7 +3031,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -2826,10 +3041,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(head); @@ -2855,6 +3074,32 @@ export class ReportController extends Controller { (x) => x.orgRevisionId == orgRevisionActive.id, ); } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { orgTreeName: orgChild2.orgChild2Name, @@ -2889,11 +3134,11 @@ export class ReportController extends Controller { (x: any) => x.positionIsSelected == true, )?.posExecutive?.posExecutiveName, profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", - reason: posMaster.reason, + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, + positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount, + mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -2911,7 +3156,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -2921,10 +3166,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(_head); @@ -2953,7 +3202,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -2964,10 +3213,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(head); @@ -2993,6 +3246,32 @@ export class ReportController extends Controller { (x) => x.orgRevisionId == orgRevisionActive.id, ); } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { orgTreeName: orgChild3.orgChild3Name, @@ -3027,11 +3306,11 @@ export class ReportController extends Controller { (x: any) => x.positionIsSelected == true, )?.posExecutive?.posExecutiveName, profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", - reason: posMaster.reason, + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, + positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount, + mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -3049,7 +3328,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -3059,10 +3338,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(_head); @@ -3092,7 +3375,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -3103,10 +3386,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(head); @@ -3132,6 +3419,32 @@ export class ReportController extends Controller { (x) => x.orgRevisionId == orgRevisionActive.id, ); } + let education: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileEducations != null && + posMaster.next_holder.profileEducations.length > 0 + ) { + let _education: any = posMaster.next_holder.profileEducations.sort( + (a, b) => b.finishDate.getTime() - a.finishDate.getTime(), + ); + if (_education.length > 0) { + education = _education[0]; + } + } + let salary: any = ""; + if ( + posMaster.next_holder != null && + posMaster.next_holder.profileSalary != null && + posMaster.next_holder.profileSalary.length > 0 + ) { + let _salary: any = posMaster.next_holder.profileSalary.sort( + (a, b) => b.date.getTime() - a.date.getTime(), + ); + if (_salary.length > 0) { + salary = _salary[0]; + } + } let node = { orgTreeName: orgChild4.orgChild4Name, @@ -3166,11 +3479,11 @@ export class ReportController extends Controller { (x: any) => x.positionIsSelected == true, )?.posExecutive?.posExecutiveName, profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", - reason: posMaster.reason, + education: education == "" ? "" : education.degree, + salary: salary == "" ? "" : salary.amount, + positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount, + mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount, + reason: posMaster.reason == null ? "" : posMaster.reason, }; if (_node == null) { const head = { @@ -3188,7 +3501,7 @@ export class ReportController extends Controller { }; data.push(head); const _head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -3198,10 +3511,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(_head); @@ -3231,7 +3548,7 @@ export class ReportController extends Controller { _node == null; } const head = { - no: no, + no: Extension.ToThaiNumber(no.toString()), posMasterNo: node.posMasterNo == null ? "" @@ -3242,10 +3559,14 @@ export class ReportController extends Controller { positionName: node.positionName, posType: node.posType, posLevel: node.posLevel, - education: "", - salary: "", - positionSalaryAmount: "", - mouthSalaryAmount: "", + education: node.education, + salary: Extension.ToThaiNumber(node.salary.toLocaleString()), + positionSalaryAmount: Extension.ToThaiNumber( + node.positionSalaryAmount.toLocaleString(), + ), + mouthSalaryAmount: Extension.ToThaiNumber( + node.mouthSalaryAmount.toLocaleString(), + ), reason: node.reason, }; data.push(head);