diff --git a/BMA.EHR.Leave/Controllers/LeaveReportController.cs b/BMA.EHR.Leave/Controllers/LeaveReportController.cs index f67ece92..0995f218 100644 --- a/BMA.EHR.Leave/Controllers/LeaveReportController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveReportController.cs @@ -137,14 +137,26 @@ namespace BMA.EHR.Leave.Service.Controllers await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(data.KeycloakUserId, data.Type.Id); - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} + + var orgName = ""; + if (profile.Child1 != null && profile.Child1 != "") + orgName += $" {profile.Child1}"; + if (profile.Child2 != null && profile.Child2 != "") + orgName += $" {profile.Child2}"; + if (profile.Child3 != null && profile.Child3 != "") + orgName += $" {profile.Child3}"; + if (profile.Child4 != null && profile.Child4 != "") + orgName += $" {profile.Child4}"; + if (profile.Root != null && profile.Root != "") + orgName += $" {profile.Root}"; var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(data.KeycloakUserId, data.Type.Id, data.LeaveStartDate.Year); @@ -157,11 +169,11 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, - organizationName = profile!.Oc ?? "", + positionLeaveName = profile!.PosLevel == null ? "-" : profile!.PosLevel, + organizationName = orgName, leaveDetail = data.LeaveDetail, leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate(), @@ -188,14 +200,26 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} + + var orgName = ""; + if (profile.Child1 != null && profile.Child1 != "") + orgName += $" {profile.Child1}"; + if (profile.Child2 != null && profile.Child2 != "") + orgName += $" {profile.Child2}"; + if (profile.Child3 != null && profile.Child3 != "") + orgName += $" {profile.Child3}"; + if (profile.Child4 != null && profile.Child4 != "") + orgName += $" {profile.Child4}"; + if (profile.Root != null && profile.Root != "") + orgName += $" {profile.Root}"; return new { @@ -206,7 +230,7 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, positionLeaveName = profile!.Position == null ? "-" : profile!.Position,