no message

This commit is contained in:
kittapath 2024-12-12 11:36:11 +07:00
parent 992a48b787
commit 9abdeca45b
5 changed files with 197 additions and 181 deletions

View file

@ -700,10 +700,10 @@ export class CommandController extends Controller {
commandSend.lastUpdateFullName = request.user.name; commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date(); commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend); await this.commandSendRepository.save(commandSend);
if(commandSend && commandSend.id) { if (commandSend && commandSend.id) {
let _ccName = new Array("EMAIL", "INBOX"); let _ccName = new Array("EMAIL", "INBOX");
let _dataSendCC = new Array(); let _dataSendCC = new Array();
for(let i=0; i<_ccName.length; i++) { for (let i = 0; i < _ccName.length; i++) {
_dataSendCC.push({ _dataSendCC.push({
commandSendId: commandSend.id, commandSendId: commandSend.id,
name: _ccName[i], name: _ccName[i],
@ -943,7 +943,7 @@ export class CommandController extends Controller {
await new permission().PermissionGet(request, "COMMAND"); await new permission().PermissionGet(request, "COMMAND");
const command = await this.commandRepository.findOne({ const command = await this.commandRepository.findOne({
where: { id }, where: { id },
relations: ["commandType"] relations: ["commandType"],
}); });
if (!command) { if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
@ -1165,7 +1165,7 @@ export class CommandController extends Controller {
await new permission().PermissionUpdate(request, "COMMAND"); await new permission().PermissionUpdate(request, "COMMAND");
const command = await this.commandRepository.findOne({ const command = await this.commandRepository.findOne({
where: { id: id }, where: { id: id },
relations: ["commandType", "commandRecives",], relations: ["commandType", "commandRecives"],
}); });
if (!command) { if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
@ -1255,7 +1255,7 @@ export class CommandController extends Controller {
let _data: any = null; let _data: any = null;
await Promise.all([ await Promise.all([
await new CallAPI() await new CallAPI()
.PostDataKeycloak("/realms/bma-ehr/protocol/openid-connect/token", data) .PostDataKeycloak(`/realms/${process.env.KC_REALM}/protocol/openid-connect/token`, data)
.then(async (x) => { .then(async (x) => {
_data = x; _data = x;
}) })
@ -1635,7 +1635,7 @@ export class CommandController extends Controller {
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
) { ) {
let command = new Command(); let command = new Command();
let commandCode:string = ""; let commandCode: string = "";
let null_: any = null; let null_: any = null;
if ( if (
requestBody.commandId != undefined && requestBody.commandId != undefined &&
@ -1826,10 +1826,10 @@ export class CommandController extends Controller {
commandSend.lastUpdateFullName = request.user.name; commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date(); commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend); await this.commandSendRepository.save(commandSend);
if(commandSend && commandSend.id) { if (commandSend && commandSend.id) {
let _ccName = new Array("EMAIL", "INBOX"); let _ccName = new Array("EMAIL", "INBOX");
let _dataSendCC = new Array(); let _dataSendCC = new Array();
for(let i=0; i<_ccName.length; i++) { for (let i = 0; i < _ccName.length; i++) {
_dataSendCC.push({ _dataSendCC.push({
commandSendId: commandSend.id, commandSendId: commandSend.id,
name: _ccName[i], name: _ccName[i],
@ -1884,10 +1884,10 @@ export class CommandController extends Controller {
commandSend.lastUpdateFullName = request.user.name; commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date(); commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend); await this.commandSendRepository.save(commandSend);
if(commandSend && commandSend.id) { if (commandSend && commandSend.id) {
let _ccName = new Array("EMAIL", "INBOX"); let _ccName = new Array("EMAIL", "INBOX");
let _dataSendCC = new Array(); let _dataSendCC = new Array();
for(let i=0; i<_ccName.length; i++) { for (let i = 0; i < _ccName.length; i++) {
_dataSendCC.push({ _dataSendCC.push({
commandSendId: commandSend.id, commandSendId: commandSend.id,
name: _ccName[i], name: _ccName[i],
@ -1936,7 +1936,7 @@ export class CommandController extends Controller {
) { ) {
await Promise.all( await Promise.all(
body.data.map(async (item) => { body.data.map(async (item) => {
const profile:any = await this.profileRepository.findOneBy({ id: item.profileId }); const profile: any = await this.profileRepository.findOneBy({ id: item.profileId });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
} }
@ -2058,7 +2058,7 @@ export class CommandController extends Controller {
) { ) {
await Promise.all( await Promise.all(
body.data.map(async (item) => { body.data.map(async (item) => {
const profile:any = await this.profileEmployeeRepository.findOneBy({ id: item.profileId }); const profile: any = await this.profileEmployeeRepository.findOneBy({ id: item.profileId });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
@ -2265,16 +2265,22 @@ export class CommandController extends Controller {
lastName: profile.lastName, lastName: profile.lastName,
}); });
// กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่ และหากยังไม่สามารถลบได้ให้แสดง Error // กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่ และหากยังไม่สามารถลบได้ให้แสดง Error
if (profile.keycloak != null && userKeycloakId && userKeycloakId.errorMessage === "User exists with same username") { if (
profile.keycloak != null &&
userKeycloakId &&
userKeycloakId.errorMessage === "User exists with same username"
) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if(delUserKeycloak) { if (delUserKeycloak) {
userKeycloakId = await createUser(profile.citizenId, profile.citizenId, { userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
firstName: profile.firstName, firstName: profile.firstName,
lastName: profile.lastName, lastName: profile.lastName,
}); });
} } else {
else { throw new HttpError(
throw new HttpError(HttpStatus.BAD_REQUEST, "พบข้อผิดพลาด ไม่สามารถจัดการผู้ใช้งานได้"); HttpStatus.BAD_REQUEST,
"พบข้อผิดพลาด ไม่สามารถจัดการผู้ใช้งานได้",
);
} }
} }
const list = await getRoles(); const list = await getRoles();
@ -2430,7 +2436,7 @@ export class CommandController extends Controller {
) { ) {
await Promise.all( await Promise.all(
body.data.map(async (item) => { body.data.map(async (item) => {
const profile:any = await this.profileRepository.findOne({ const profile: any = await this.profileRepository.findOne({
where: { id: item.profileId }, where: { id: item.profileId },
relations: ["roleKeycloaks"], relations: ["roleKeycloaks"],
}); });
@ -3792,7 +3798,9 @@ export class CommandController extends Controller {
if ( if (
orgRevision != null && orgRevision != null &&
!["REPORT", "DONE"].includes( !["REPORT", "DONE"].includes(
orgRevision.posMasters.find((x) => x.statusReport === "REPORT" || x.statusReport === "DONE")?.statusReport || "", orgRevision.posMasters.find(
(x) => x.statusReport === "REPORT" || x.statusReport === "DONE",
)?.statusReport || "",
) )
) { ) {
await this.orgRevisionRepo.update(orgRevision.id, { await this.orgRevisionRepo.update(orgRevision.id, {

View file

@ -37,7 +37,7 @@ export class LoginController extends Controller {
let _data: any = null; let _data: any = null;
await Promise.all([ await Promise.all([
await new CallAPI() await new CallAPI()
.PostDataKeycloak("/realms/bma-ehr/protocol/openid-connect/token", data) .PostDataKeycloak(`/realms/${process.env.KC_REALM}/protocol/openid-connect/token`, data)
.then(async (x) => { .then(async (x) => {
_data = x; _data = x;
}) })

View file

@ -278,7 +278,7 @@ export class ProfileController extends Controller {
: "-", : "-",
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
educations: Education, educations: Education,
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`,
}; };
return new HttpSuccess({ return new HttpSuccess({
@ -715,7 +715,7 @@ export class ProfileController extends Controller {
: "", : "",
telephone: telephone:
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`,
url1: _ImgUrl[0] ? _ImgUrl[0] : null, url1: _ImgUrl[0] ? _ImgUrl[0] : null,
yearUpload1: profiles.profileAvatars[0] yearUpload1: profiles.profileAvatars[0]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt)) ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt))
@ -1839,7 +1839,7 @@ export class ProfileController extends Controller {
const profile = Object.assign(new Profile(), body); const profile = Object.assign(new Profile(), body);
profile.prefixMain = profile.prefix; profile.prefixMain = profile.prefix;
profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain;
profile.isProbation = false; profile.isProbation = false;
profile.isLeave = false; profile.isLeave = false;
profile.createdUserId = request.user.sub; profile.createdUserId = request.user.sub;
@ -1912,7 +1912,7 @@ export class ProfileController extends Controller {
const profile: Profile = Object.assign(new Profile(), body); const profile: Profile = Object.assign(new Profile(), body);
const _null: any = null; const _null: any = null;
profile.prefixMain = profile.prefix; profile.prefixMain = profile.prefix;
profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain;
profile.dateRetire = body.birthDate == null ? _null : calculateRetireDate(body.birthDate); profile.dateRetire = body.birthDate == null ? _null : calculateRetireDate(body.birthDate);
profile.dateRetireLaw = body.birthDate == null ? _null : calculateRetireLaw(body.birthDate); profile.dateRetireLaw = body.birthDate == null ? _null : calculateRetireLaw(body.birthDate);
profile.createdUserId = request.user.sub; profile.createdUserId = request.user.sub;
@ -1981,7 +1981,7 @@ export class ProfileController extends Controller {
} }
const profile: Profile = Object.assign(new Profile(), body); const profile: Profile = Object.assign(new Profile(), body);
profile.prefixMain = profile.prefix; profile.prefixMain = profile.prefix;
profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain;
profile.createdUserId = request.user.sub; profile.createdUserId = request.user.sub;
profile.createdFullName = request.user.name; profile.createdFullName = request.user.name;
profile.lastUpdateUserId = request.user.sub; profile.lastUpdateUserId = request.user.sub;
@ -3553,7 +3553,7 @@ export class ProfileController extends Controller {
Object.assign(record, body); Object.assign(record, body);
record.prefixMain = record.prefix; record.prefixMain = record.prefix;
record.prefix = record.rank && record.rank.length > 0?record.rank:record.prefixMain; record.prefix = record.rank && record.rank.length > 0 ? record.rank : record.prefixMain;
record.createdUserId = request.user.sub; record.createdUserId = request.user.sub;
record.createdFullName = request.user.name; record.createdFullName = request.user.name;
record.createdAt = new Date(); record.createdAt = new Date();
@ -3804,7 +3804,7 @@ export class ProfileController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("current_holders.orgRevisionId = :orgRevisionId", {orgRevisionId: findRevision.id}) .where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: findRevision.id })
.andWhere( .andWhere(
posType != undefined && posType != null && posType != "" posType != undefined && posType != null && posType != ""
? "posType.posTypeName LIKE :keyword1" ? "posType.posTypeName LIKE :keyword1"
@ -4156,7 +4156,7 @@ export class ProfileController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("current_holders.orgRevisionId = :orgRevisionId", {orgRevisionId: findRevision.id}) .where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: findRevision.id })
.andWhere( .andWhere(
_data.root != undefined && _data.root != null _data.root != undefined && _data.root != null
? _data.root[0] != null ? _data.root[0] != null
@ -4248,8 +4248,8 @@ export class ProfileController extends Controller {
{ {
keyword: `%${searchKeyword}%`, keyword: `%${searchKeyword}%`,
}, },
) );
}) }),
) )
.orderBy("current_holders.posMasterNo", "ASC") .orderBy("current_holders.posMasterNo", "ASC")
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
@ -6004,7 +6004,7 @@ export class ProfileController extends Controller {
) { ) {
let findProfile: any; let findProfile: any;
let total: any; let total: any;
let revision = await this.orgRevisionRepo.findOne({where: { orgRevisionIsCurrent: true }}); let revision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } });
const skip = (page - 1) * pageSize; const skip = (page - 1) * pageSize;
const take = pageSize; const take = pageSize;
let queryLike = `CONCAT( let queryLike = `CONCAT(
@ -6029,9 +6029,9 @@ export class ProfileController extends Controller {
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
citizenId: Like(`%${body.keyword}%`), citizenId: Like(`%${body.keyword}%`),
current_holders:{ current_holders: {
orgRevisionId:revision?.id orgRevisionId: revision?.id,
} },
}, },
relations: [ relations: [
"posType", "posType",
@ -6050,7 +6050,8 @@ export class ProfileController extends Controller {
break; break;
case "fullName": case "fullName":
[findProfile, total] = await this.profileRepo.createQueryBuilder("profile") [findProfile, total] = await this.profileRepo
.createQueryBuilder("profile")
.leftJoinAndSelect("profile.posType", "posType") .leftJoinAndSelect("profile.posType", "posType")
.leftJoinAndSelect("profile.posLevel", "posLevel") .leftJoinAndSelect("profile.posLevel", "posLevel")
.leftJoinAndSelect("profile.current_holders", "current_holders") .leftJoinAndSelect("profile.current_holders", "current_holders")
@ -6060,7 +6061,10 @@ export class ProfileController extends Controller {
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("current_holders.orgRevision = :revisionId", { revisionId: revision?.id }) .where("current_holders.orgRevision = :revisionId", { revisionId: revision?.id })
.andWhere("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` }) .andWhere(
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword",
{ keyword: `%${body.keyword}%` },
)
.skip(skip) .skip(skip)
.take(take) .take(take)
.getManyAndCount(); .getManyAndCount();
@ -6070,9 +6074,9 @@ export class ProfileController extends Controller {
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
position: Like(`%${body.keyword}%`), position: Like(`%${body.keyword}%`),
current_holders:{ current_holders: {
orgRevisionId:revision?.id orgRevisionId: revision?.id,
} },
}, },
relations: [ relations: [
"posType", "posType",
@ -6091,7 +6095,8 @@ export class ProfileController extends Controller {
break; break;
case "posNo": case "posNo":
[findProfile, total] = await this.profileRepo.createQueryBuilder("profile") [findProfile, total] = await this.profileRepo
.createQueryBuilder("profile")
.leftJoinAndSelect("profile.posType", "posType") .leftJoinAndSelect("profile.posType", "posType")
.leftJoinAndSelect("profile.posLevel", "posLevel") .leftJoinAndSelect("profile.posLevel", "posLevel")
.leftJoinAndSelect("profile.current_holders", "current_holders") .leftJoinAndSelect("profile.current_holders", "current_holders")
@ -6103,13 +6108,15 @@ export class ProfileController extends Controller {
.where("current_holders.orgRevision = :revisionId", { revisionId: revision?.id }) .where("current_holders.orgRevision = :revisionId", { revisionId: revision?.id })
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.orWhere(body.keyword != undefined && body.keyword != null && body.keyword != "" qb.orWhere(
body.keyword != undefined && body.keyword != null && body.keyword != ""
? queryLike ? queryLike
: "1=1", : "1=1",
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
}) },
}) );
}),
) )
.skip(skip) .skip(skip)
.take(take) .take(take)
@ -6120,11 +6127,11 @@ export class ProfileController extends Controller {
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
posType: { posType: {
posTypeName:Like(`%${body.keyword}%`) posTypeName: Like(`%${body.keyword}%`),
},
current_holders: {
orgRevisionId: revision?.id,
}, },
current_holders:{
orgRevisionId:revision?.id
}
}, },
relations: [ relations: [
"posType", "posType",
@ -6146,11 +6153,11 @@ export class ProfileController extends Controller {
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
posLevel: { posLevel: {
posLevelName:Like(`%${body.keyword}%`) posLevelName: Like(`%${body.keyword}%`),
},
current_holders: {
orgRevisionId: revision?.id,
}, },
current_holders:{
orgRevisionId:revision?.id
}
}, },
relations: [ relations: [
"posType", "posType",
@ -6171,12 +6178,13 @@ export class ProfileController extends Controller {
case "organization": case "organization":
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
current_holders:{ current_holders: {
orgRevisionId:revision?.id, orgRevisionId: revision?.id,
orgRoot:{ orgRoot: {
orgRootName:Like(`%${body.keyword}%`) orgRootName: Like(`%${body.keyword}%`),
} },
}}, },
},
relations: [ relations: [
"posType", "posType",
"posLevel", "posLevel",
@ -6195,10 +6203,10 @@ export class ProfileController extends Controller {
default: default:
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where:{ where: {
current_holders:{ current_holders: {
orgRevisionId:revision?.id orgRevisionId: revision?.id,
} },
}, },
relations: [ relations: [
"posType", "posType",
@ -7251,7 +7259,7 @@ export class ProfileController extends Controller {
// item.current_holder == null || item.current_holder.profileSalary.length == 0 // item.current_holder == null || item.current_holder.profileSalary.length == 0
// ? null // ? null
// : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
const amount = item.current_holder?item.current_holder.amount:null; const amount = item.current_holder ? item.current_holder.amount : null;
let datePeriodStart = new Date( let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
); );
@ -8061,7 +8069,7 @@ export class ProfileController extends Controller {
} }
profile.prefixMain = profile.prefix; profile.prefixMain = profile.prefix;
profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain;
profile.createdUserId = request.user.sub; profile.createdUserId = request.user.sub;
profile.createdFullName = request.user.name; profile.createdFullName = request.user.name;
profile.lastUpdateUserId = request.user.sub; profile.lastUpdateUserId = request.user.sub;

View file

@ -284,7 +284,7 @@ export class ProfileEmployeeController extends Controller {
: "-", : "-",
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
educations: Education, educations: Education,
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`,
}; };
return new HttpSuccess({ return new HttpSuccess({
@ -722,7 +722,7 @@ export class ProfileEmployeeController extends Controller {
: "", : "",
telephone: telephone:
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`,
url1: _ImgUrl[0] ? _ImgUrl[0] : null, url1: _ImgUrl[0] ? _ImgUrl[0] : null,
yearUpload1: profiles.profileAvatars[0] yearUpload1: profiles.profileAvatars[0]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt)) ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt))
@ -830,7 +830,7 @@ export class ProfileEmployeeController extends Controller {
const profile = Object.assign(new ProfileEmployee(), body); const profile = Object.assign(new ProfileEmployee(), body);
profile.prefixMain = profile.prefix; profile.prefixMain = profile.prefix;
profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain;
profile.createdUserId = request.user.sub; profile.createdUserId = request.user.sub;
profile.createdFullName = request.user.name; profile.createdFullName = request.user.name;
profile.lastUpdateUserId = request.user.sub; profile.lastUpdateUserId = request.user.sub;
@ -927,7 +927,7 @@ export class ProfileEmployeeController extends Controller {
Object.assign(record, body); Object.assign(record, body);
record.prefixMain = record.prefix; record.prefixMain = record.prefix;
record.prefix = record.rank && record.rank.length > 0?record.rank:record.prefixMain; record.prefix = record.rank && record.rank.length > 0 ? record.rank : record.prefixMain;
record.createdUserId = request.user.sub; record.createdUserId = request.user.sub;
record.createdFullName = request.user.name; record.createdFullName = request.user.name;
record.createdAt = new Date(); record.createdAt = new Date();
@ -2954,7 +2954,7 @@ export class ProfileEmployeeController extends Controller {
// item.current_holder == null || item.current_holder.profileSalary.length == 0 // item.current_holder == null || item.current_holder.profileSalary.length == 0
// ? null // ? null
// : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
const amount = item.current_holder?item.current_holder.amount:null; const amount = item.current_holder ? item.current_holder.amount : null;
let datePeriodStart = new Date( let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
); );

View file

@ -281,7 +281,7 @@ export class ProfileEmployeeTempController extends Controller {
: "-", : "-",
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
educations: Education, educations: Education,
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`,
}; };
return new HttpSuccess({ return new HttpSuccess({
@ -719,7 +719,7 @@ export class ProfileEmployeeTempController extends Controller {
: "", : "",
telephone: telephone:
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`,
url1: _ImgUrl[0] ? _ImgUrl[0] : null, url1: _ImgUrl[0] ? _ImgUrl[0] : null,
yearUpload1: profiles.profileAvatars[0] yearUpload1: profiles.profileAvatars[0]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt)) ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt))
@ -2703,7 +2703,7 @@ export class ProfileEmployeeTempController extends Controller {
// item.current_holder == null || item.current_holder.profileSalary.length == 0 // item.current_holder == null || item.current_holder.profileSalary.length == 0
// ? null // ? null
// : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
const amount = item.current_holder?item.current_holder.amount:null; const amount = item.current_holder ? item.current_holder.amount : null;
let datePeriodStart = new Date( let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
); );