add parent

This commit is contained in:
kittapath 2025-10-07 11:13:28 +07:00
parent ddf899ce5d
commit 9e8fe1b30a
22 changed files with 289 additions and 122 deletions

22
.github/workflows/discord-notify.yml vendored Normal file
View file

@ -0,0 +1,22 @@
name: Discord PR Notify
on:
pull_request:
types: [opened]
jobs:
discord:
runs-on: ubuntu-latest
steps:
- name: Send Discord
run: |
curl -X POST "${{ secrets.DISCORD_WEBHOOK_PULLREQUEST }}" \
-H "Content-Type: application/json" \
-d '{
"embeds": [{
"title": "🔔 **Service:** ${{ github.repository }}",
"description": "👤 **Author:** ${{ github.event.pull_request.user.login }}\n🌿 **Branch:** ${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }}\n📦 **Pull Request:** [#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})",
"color": 5814783,
"timestamp": "${{ github.event.pull_request.created_at }}"
}]
}'

View file

@ -331,7 +331,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
var endFiscalDate = new DateTime(year, 9, 30);
rawData = rawData.Where(x => x.LeaveStartDate >= startFiscalDate && x.LeaveStartDate <= endFiscalDate);
}
if (type != Guid.Empty)
rawData = rawData.Where(x => x.Type.Id == type);
@ -358,6 +358,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
rawData = rawData
.Where(x => x.RootDnaId == Guid.Parse(nodeId!));
}
else if (role == "PARENT")
{
rawData = rawData
.Where(x => x.Child1DnaId == Guid.Parse(nodeId!));
}
else if (role == "NORMAL")
{
rawData = rawData
@ -479,7 +484,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return data;
}
public async Task<LeaveRequest?> GetLastLeaveRequestByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId,DateTime beforeDate)
public async Task<LeaveRequest?> GetLastLeaveRequestByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, DateTime beforeDate)
{
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
.Include(x => x.Type)
@ -525,6 +530,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
rawData = rawData
.Where(x => x.RootDnaId == Guid.Parse(nodeId!));
}
else if (role == "PARENT")
{
rawData = rawData
.Where(x => x.Child1DnaId == Guid.Parse(nodeId!));
}
else if (role == "NORMAL")
{
rawData = rawData
@ -572,8 +582,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ");
//var _result = await _res.Content.ReadAsStringAsync();
}
}
}
// Send Noti
var noti = new Notification
@ -656,7 +666,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.OrderBy(x => x.Seq)
.ToList();
foreach(var commander in commanders)
foreach (var commander in commanders)
{
var noti1 = new Notification
{
@ -671,7 +681,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
await _appDbContext.SaveChangesAsync();
}
public async Task RejectCancelLeaveRequestAsync(Guid id, string Reason)
@ -1247,7 +1257,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.Type)
//.Where(x => x.LeaveStartDate.Year == year)
.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate)
//.Where(x => x.LeaveStatus == "NEW") // fix issue : #729
//.Where(x => x.LeaveStatus == "NEW") // fix issue : #729
.Where(x => x.LeaveStatus != "DRAFT") // fix issue : #1524
.ToListAsync();
@ -1468,38 +1478,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
public async Task<List<GetSumApproveLeaveByRootDto>> GetSumApproveLeaveByRootAndRange(DateTime startDate, DateTime endDate, string type, string role, string? nodeId, int? node, string? nodeIdByReq, int? nodeByReq)
{
// var _nodeId = Guid.Parse(nodeId);
var data = new List<LeaveRequest>();
//if (role == "OWNER" || role == "CHILD")
//{
// data = await _dbContext.Set<LeaveRequest>().AsQueryable()
// .Include(x => x.Type)
// .Where(x => x.ProfileType == type.Trim().ToUpper())
// .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
// .Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true))))))
// .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
//}
//else
//{
// data = await _dbContext.Set<LeaveRequest>().AsQueryable()
// .Include(x => x.Type)
// .Where(x => x.ProfileType == type.Trim().ToUpper())
// .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
// .Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true))))))
// .Where(x => node == 0 ? x.Child1Id == null : (node == 1 ? x.Child2Id == null : (node == 2 ? x.Child3Id == null : (node == 3 ? x.Child4Id == null : true))))
// .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
//}
data = await _dbContext.Set<LeaveRequest>().AsQueryable()
.Include(x => x.Type)
.Where(x => x.ProfileType == type.Trim().ToUpper())
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
// กรองตามสิทธิ์ admin ก่อน
if (role == "OWNER")
{
node = null;
}
if (role == "OWNER" || role == "CHILD")
if (role == "CHILD")
{
data = data.Where(x =>
node == 4 ? x.Child4DnaId == Guid.Parse(nodeId) :
@ -1514,6 +1500,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
{
data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId)).ToList();
}
else if (role == "PARENT")
{
data = data.Where(x => x.Child1DnaId == Guid.Parse(nodeId)).ToList();
}
else if (role == "NORMAL")
{
data = data.Where(x =>
@ -1525,7 +1515,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
).ToList();
}
// กรองตามที่ fe ส่งมา
if (role == "ROOT" || role == "OWNER" || role == "CHILD")
if (role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT")
{
data = data
.Where(x => nodeByReq == 4 ? x.Child4Id == Guid.Parse(nodeIdByReq) : nodeByReq == 3 ? x.Child3Id == Guid.Parse(nodeIdByReq) : nodeByReq == 2 ? x.Child2Id == Guid.Parse(nodeIdByReq) : nodeByReq == 1 ? x.Child1Id == Guid.Parse(nodeIdByReq) : nodeByReq == 0 ? x.RootId == Guid.Parse(nodeIdByReq) : true)

View file

@ -165,6 +165,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
data = data
.Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
}
else if (role == "PARENT")
{
data = data
.Where(x => x.Child1DnaId == Guid.Parse(nodeId!)).ToList();
}
else if (role == "NORMAL")
{
data = data

View file

@ -141,37 +141,13 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
public async Task<List<ProcessUserTimeStamp>> GetTimestampByDateLateAsync(string type, string role, string nodeId, int? node, string nodeIdByReq, int? nodeByReq, DateTime StartDate, DateTime EndDate)
{
var _nodeId = role != "OWNER" ? Guid.Parse(nodeId) : Guid.Parse("00000000-0000-0000-0000-000000000000");
var data = new List<ProcessUserTimeStamp>();
//if (role == "OWNER" || role == "CHILD")
//{
// data = await _dbContext.Set<ProcessUserTimeStamp>().AsQueryable()
// .Where(x => x.CheckInStatus == "LATE")
// .Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate)
// .Where(x => x.ProfileType == type.Trim().ToUpper())
// .Where(x => node == 4 ? x.Child4Id == _nodeId : (node == 3 ? x.Child3Id == _nodeId : (node == 2 ? x.Child2Id == _nodeId : (node == 1 ? x.Child1Id == _nodeId : (node == 0 ? x.RootId == _nodeId : true)))))
// .ToListAsync();
//}
//else
//{
// data = await _dbContext.Set<ProcessUserTimeStamp>().AsQueryable()
// .Where(x => x.CheckInStatus == "LATE")
// .Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate)
// .Where(x => x.ProfileType == type.Trim().ToUpper())
// .Where(x => node == 4 ? x.Child4Id == _nodeId : (node == 3 ? x.Child3Id == _nodeId : (node == 2 ? x.Child2Id == _nodeId : (node == 1 ? x.Child1Id == _nodeId : (node == 0 ? x.RootId == _nodeId : true)))))
// .Where(x => node == 0 ? x.Child1Id == null : (node == 1 ? x.Child2Id == null : (node == 2 ? x.Child3Id == null : (node == 3 ? x.Child4Id == null : true))))
// .ToListAsync();
//}
data = await _dbContext.Set<ProcessUserTimeStamp>().AsQueryable()
.Where(x => x.CheckInStatus == "LATE")
.Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate)
.Where(x => x.ProfileType == type.Trim().ToUpper()).ToListAsync();
// กรองตามสิทธิ์ admin ก่อน
if (role == "OWNER")
{
node = null;
}
if (role == "OWNER" || role == "CHILD")
if (role == "CHILD")
{
data = data.Where(x =>
node == 4 ? x.Child4DnaId == Guid.Parse(nodeId) :
@ -186,6 +162,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
{
data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId)).ToList();
}
else if (role == "PARENT")
{
data = data.Where(x => x.Child1DnaId == Guid.Parse(nodeId)).ToList();
}
else if (role == "NORMAL")
{
data = data.Where(x =>
@ -197,7 +177,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
).ToList();
}
// กรองตามที่ fe ส่งมา
if (role == "ROOT" || role == "OWNER" || role == "CHILD")
if (role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT")
{
data = data.Where(x =>
nodeByReq == 4 ? x.Child4Id == Guid.Parse(nodeIdByReq) :
@ -288,6 +268,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
.Where(x => x.RootDnaId == Guid.Parse(nodeId!))
.ToList();
}
else if (role == "PARENT")
{
data = data
.Where(x => x.Child1DnaId == Guid.Parse(nodeId!))
.ToList();
}
else if (role == "NORMAL")
{
data = data

View file

@ -90,7 +90,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
.Where(u => u.KeycloakUserId == keycloakId)
.Where(u => u.CheckIn.Year == year)
.OrderBy(u => u.CheckIn)
.ToListAsync();
return data;
@ -101,7 +101,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
var data = await _dbContext.Set<UserTimeStamp>()
.Where(u => u.CheckIn.Date >= startDate.Date && u.CheckIn.Date <= endDate.Date)
.OrderBy(u => u.CheckIn)
.ToListAsync();
return data;
@ -130,6 +130,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
.Where(x => x.RootDnaId == Guid.Parse(nodeId!))
.ToList();
}
else if (role == "PARENT")
{
data = data
.Where(x => x.Child1DnaId == Guid.Parse(nodeId!))
.ToList();
}
else if (role == "NORMAL")
{
data = data

View file

@ -143,7 +143,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
CreatedAt = x.CreatedAt
});
if (!string.IsNullOrEmpty(sortBy))
{
{
{
if (sortBy == "title")
query = descending ? query.OrderByDescending(x => x.Title) : query.OrderBy(x => x.Title);
@ -172,9 +172,9 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
}
}
else
{
query = query.OrderByDescending(x => x.CreatedAt);
}
{
query = query.OrderByDescending(x => x.CreatedAt);
}
var data = query
.Skip((page - 1) * pageSize)
@ -776,6 +776,10 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var data_search = (from x in _context.DisciplineComplaint_Appeals
@ -807,6 +811,11 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
data_search = data_search
.Where(x => x.rootDnaId == nodeId).ToList();
}
else if (role == "PARENT")
{
data_search = data_search
.Where(x => x.child1DnaId == nodeId).ToList();
}
else if (role == "NORMAL")
{
data_search = data_search

View file

@ -74,20 +74,6 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
{
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
//var profile = new List<GetProfileByKeycloakIdRootDto>();
//if (type.Trim().ToUpper() == "OFFICER")
//{
// profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
//}
//else
//{
// profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
//}
//if (req.posLevel != null || req.posType != null)
//{
// profile = profile.Where(x => x.PositionType == req.posType || x.PositionLevel == req.posLevel).ToList();
//}
var data_search1 = await _context.DisciplineComplaints
.Include(x => x.DisciplineComplaint_Profiles)

View file

@ -627,6 +627,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
@ -703,6 +707,11 @@ namespace BMA.EHR.Insignia.Service.Controllers
rawData = rawData
.Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
}
else if (role == "PARENT")
{
rawData = rawData
.Where(x => x.Child1DnaId == Guid.Parse(nodeId!)).ToList();
}
else if (role == "NORMAL")
{
rawData = rawData
@ -903,6 +912,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
@ -977,6 +990,11 @@ namespace BMA.EHR.Insignia.Service.Controllers
rawData = rawData
.Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
}
else if (role == "PARENT")
{
rawData = rawData
.Where(x => x.Child1DnaId == Guid.Parse(nodeId!)).ToList();
}
else if (role == "NORMAL")
{
rawData = rawData

View file

@ -1297,6 +1297,10 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
//var data = (await _userTimeStampRepository.GetTimeStampHistoryForAdminAsync(startDate, endDate))
var data = (await _userTimeStampRepository.GetTimeStampHistoryForAdminRoleAsync(startDate, endDate, role, nodeId, profileAdmin?.Node))
@ -1535,6 +1539,10 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
//var resultData = await _processUserTimeStampRepository.GetTimeStampHistoryForAdminAsync(startDate, endDate);
var resultData = await _processUserTimeStampRepository.GetTimeStampHistoryForAdminRoleAsync(startDate, endDate, role, nodeId, profileAdmin?.Node);
var data = new List<CheckInProcessHistoryForAdminDto>();
@ -2205,6 +2213,10 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
//var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequests(year, month);
var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequestsByAdminRole(year, month, role, nodeId, profileAdmin?.Node);

View file

@ -972,29 +972,27 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
if (type.Trim().ToUpper() == "OFFICER")
{
//profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficerAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId);
//profile = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllOfficerAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId);
profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
}
else
{
//profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployeeAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId);
//profile = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllEmployeeAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId);
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
}
// get leave day
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
var count = 1;
var employees = new List<dynamic>();
// กรองตามที่ fe ส่งมา
if (role == "CHILD" && req.node > profileAdmin?.Node)
if ((role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT") && req.node > profileAdmin?.Node)
{
profile = profile
.Where(x => req.node == 4 ? x.OrgChild4Id == req.nodeId : req.node == 3 ? x.OrgChild3Id == req.nodeId : req.node == 2 ? x.OrgChild2Id == req.nodeId : req.node == 1 ? x.OrgChild1Id == req.nodeId : req.node == 0 ? x.OrgRootId == req.nodeId : true)
@ -1595,16 +1593,17 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
if (type.Trim().ToUpper() == "OFFICER")
{
//profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
//profile = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllOfficer(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
}
else
{
//profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
//profile = await _userProfileRepository.GketProfileWithNoneValidateKeycloakAllEmployee(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
}
var date = req.StartDate.Date;
@ -1668,7 +1667,7 @@ namespace BMA.EHR.Leave.Service.Controllers
var workTotal = 0;
var seminarTotal = 0;
// กรองตามที่ fe ส่งมา
if (role == "CHILD" && req.node > profileAdmin?.Node)
if ((role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT") && req.node > profileAdmin?.Node)
{
profile = profile
.Where(x => req.node == 4 ? x.OrgChild4Id == req.nodeId : req.node == 3 ? x.OrgChild3Id == req.nodeId : req.node == 2 ? x.OrgChild2Id == req.nodeId : req.node == 1 ? x.OrgChild1Id == req.nodeId : req.node == 0 ? x.OrgRootId == req.nodeId : true)
@ -1924,6 +1923,11 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
if (type.Trim().ToUpper() == "OFFICER")
{
profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
@ -1933,7 +1937,7 @@ namespace BMA.EHR.Leave.Service.Controllers
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
}
// Child กรองตามที่ fe ส่งมาอีกชั้น
if (role == "CHILD" && req.node > profileAdmin?.Node)
if ((role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT") && req.node > profileAdmin?.Node)
{
profile = profile
.Where(x => req.node == 4 ? x.OrgChild4Id == req.nodeId : req.node == 3 ? x.OrgChild3Id == req.nodeId : req.node == 2 ? x.OrgChild2Id == req.nodeId : req.node == 1 ? x.OrgChild1Id == req.nodeId : req.node == 0 ? x.OrgRootId == req.nodeId : true)
@ -1993,7 +1997,7 @@ namespace BMA.EHR.Leave.Service.Controllers
var studyTotal = 0;
var workTotal = 0;
var seminarTotal = 0;
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
if (defaultRound == null)
{
@ -2315,7 +2319,10 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
//var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper(), jsonData["result"]?.ToString(), req.nodeId, req.node, req.StartDate, req.EndDate);
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper(), role, nodeId, profileAdmin.Node, req.nodeId, req.node, req.StartDate, req.EndDate);
foreach (var p in userTimeStamps)
{
@ -2424,6 +2431,10 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByRootAndRange(req.StartDate, req.EndDate, type, jsonData["result"]?.ToString(), nodeId, profileAdmin?.Node, req.nodeId, req.node);
var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate().ToThaiNumber()}";
var result = new

View file

@ -1007,8 +1007,8 @@ namespace BMA.EHR.Leave.Service.Controllers
var sumApproveLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(userId, req.Type, req.StartLeaveDate.Year);
// อ่านค่าจากตาราง beginning ทั้ง limit และ usage
var fiscalYear = req.StartLeaveDate.Year;
if(req.StartLeaveDate.Date >= new DateTime(DateTime.Now.Year,10,1) && req.EndLeaveDate.Date <= new DateTime(DateTime.Now.Year,12,31))
var fiscalYear = req.StartLeaveDate.Year;
if (req.StartLeaveDate.Date >= new DateTime(DateTime.Now.Year, 10, 1) && req.EndLeaveDate.Date <= new DateTime(DateTime.Now.Year, 12, 31))
fiscalYear = req.StartLeaveDate.Year + 1;
var sumLeaveDay = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(fiscalYear, req.Type, userId);
@ -1661,28 +1661,6 @@ namespace BMA.EHR.Leave.Service.Controllers
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
//// เพิ่มเติมการดึงคนตามสิทธิ์แบบที่ bright ทำ #1462
//var profileList = new List<GetProfileByKeycloakIdRootDto>();
//if (req.ProfileType.Trim().ToUpper() == "OFFICER")
//{
// profileList = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllOfficerAndRevision(AccessToken, req.Node, req.NodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.RevisionId);
//}
//else
//{
// profileList = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllEmployeeAndRevision(AccessToken, req.Node, req.NodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.RevisionId);
//}
//var keycloakList = new List<Guid>();
//if(profileList != null)
//{
// keycloakList = profileList.Where(x => x.Keycloak != null).Select(x => x.Keycloak!.Value).ToList();
//}
//var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminWithAuthAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, keycloakList);
//var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate);
string role = jsonData["result"]?.ToString();
var nodeId = string.Empty;
var profileAdmin = new GetUserOCAllDto();
@ -1705,6 +1683,10 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var rawData = await _leaveRequestRepository.GetListLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, role, nodeId, profileAdmin?.Node);
@ -1890,6 +1872,10 @@ namespace BMA.EHR.Leave.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var rawData =
await _leaveRequestRepository.GetCancelLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, role, nodeId, profileAdmin?.Node);
@ -2335,7 +2321,7 @@ namespace BMA.EHR.Leave.Service.Controllers
//approver = list.First().Name;
//}
//var sumLeave = rawData.LeaveStartDate.DiffDay(rawData.LeaveEndDate);
//var sumHoliday = await _holidayRepository.GetHolidayCountAsync(rawData.LeaveStartDate, rawData.LeaveEndDate, category);
@ -2599,8 +2585,8 @@ namespace BMA.EHR.Leave.Service.Controllers
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
var thisYear = DateTime.Now.Year;
var toDay = DateTime.Now.Date;
if(toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
thisYear = thisYear + 1;
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
thisYear = thisYear + 1;
var sendList = await _leaveRequestRepository.GetSumSendLeaveAsync(thisYear);
//var approveList = await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear);

View file

@ -103,6 +103,10 @@ namespace BMA.EHR.Placement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var placementAppointments = await _context.PlacementAppointments.AsQueryable()
@ -221,6 +225,11 @@ namespace BMA.EHR.Placement.Service.Controllers
placementAppointments = placementAppointments
.Where(x => x.rootDnaId == nodeId).ToList();
}
else if (role == "PARENT")
{
placementAppointments = placementAppointments
.Where(x => x.child1DnaId == nodeId).ToList();
}
else if (role == "NORMAL")
{
placementAppointments = placementAppointments

View file

@ -102,6 +102,10 @@ namespace BMA.EHR.Placement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var placementAppointments = await _context.PlacementAppointments.AsQueryable()
@ -215,6 +219,11 @@ namespace BMA.EHR.Placement.Service.Controllers
placementAppointments = placementAppointments
.Where(x => x.rootDnaId == nodeId).ToList();
}
else if (role == "PARENT")
{
placementAppointments = placementAppointments
.Where(x => x.child1DnaId == nodeId).ToList();
}
else if (role == "NORMAL")
{
placementAppointments = placementAppointments

View file

@ -103,6 +103,10 @@ namespace BMA.EHR.Placement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var placementOfficers = await _context.PlacementOfficers.AsQueryable()
@ -176,6 +180,11 @@ namespace BMA.EHR.Placement.Service.Controllers
placementOfficers = placementOfficers
.Where(x => x.rootDnaOldId == nodeId).ToList();
}
else if (role == "PARENT")
{
placementOfficers = placementOfficers
.Where(x => x.child1DnaOldId == nodeId).ToList();
}
else if (role == "NORMAL")
{
placementOfficers = placementOfficers

View file

@ -104,6 +104,10 @@ namespace BMA.EHR.Placement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var placementReceives = await _context.PlacementReceives.AsQueryable()
@ -214,6 +218,11 @@ namespace BMA.EHR.Placement.Service.Controllers
placementReceives = placementReceives
.Where(x => (x.rootDnaId == nodeId) || (x.CreatedUserId == UserId)).ToList();
}
else if (role == "PARENT")
{
placementReceives = placementReceives
.Where(x => (x.child1DnaId == nodeId) || (x.CreatedUserId == UserId)).ToList();
}
else if (role == "NORMAL")
{
placementReceives = placementReceives
@ -521,7 +530,7 @@ namespace BMA.EHR.Placement.Service.Controllers
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org != null && org.result != null)
{
placementReceive.profileId = org.result.profileId;

View file

@ -104,6 +104,10 @@ namespace BMA.EHR.Placement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var placementRepatriations = await _context.PlacementRepatriations.AsQueryable()
@ -181,6 +185,11 @@ namespace BMA.EHR.Placement.Service.Controllers
placementRepatriations = placementRepatriations
.Where(x => x.rootDnaOldId == nodeId).ToList();
}
else if (role == "PARENT")
{
placementRepatriations = placementRepatriations
.Where(x => x.child1DnaOldId == nodeId).ToList();
}
else if (role == "NORMAL")
{
placementRepatriations = placementRepatriations

View file

@ -196,6 +196,10 @@ namespace BMA.EHR.Placement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var placementTransfers = await _context.PlacementTransfers.AsQueryable()
@ -267,6 +271,11 @@ namespace BMA.EHR.Placement.Service.Controllers
placementTransfers = placementTransfers
.Where(x => x.rootDnaOldId == nodeId).ToList();
}
else if (role == "PARENT")
{
placementTransfers = placementTransfers
.Where(x => x.child1DnaOldId == nodeId).ToList();
}
else if (role == "NORMAL")
{
placementTransfers = placementTransfers

View file

@ -108,6 +108,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var retirementDeceaseds = await _context.RetirementDeceaseds.AsQueryable()
@ -160,6 +164,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
retirementDeceaseds = retirementDeceaseds
.Where(x => x.rootDnaId == nodeId).ToList();
}
else if (role == "PARENT")
{
retirementDeceaseds = retirementDeceaseds
.Where(x => x.child1DnaId == nodeId).ToList();
}
else if (role == "NORMAL")
{
retirementDeceaseds = retirementDeceaseds

View file

@ -104,6 +104,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var retirementOthers = await _context.RetirementOthers.AsQueryable()
@ -210,6 +214,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
retirementOthers = retirementOthers
.Where(x => x.rootDnaOldId == nodeId).ToList();
}
else if (role == "PARENT")
{
retirementOthers = retirementOthers
.Where(x => x.child1DnaOldId == nodeId).ToList();
}
else if (role == "NORMAL")
{
retirementOthers = retirementOthers

View file

@ -119,6 +119,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var retirementOuts = await _context.RetirementOuts.AsQueryable()
@ -191,6 +195,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
retirementOuts = retirementOuts
.Where(x => x.rootDnaOldId == nodeId).ToList();
}
else if (role == "PARENT")
{
retirementOuts = retirementOuts
.Where(x => x.child1DnaOldId == nodeId).ToList();
}
else if (role == "NORMAL")
{
retirementOuts = retirementOuts

View file

@ -261,6 +261,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var retirementResigns = await _context.RetirementResigns.AsQueryable()
@ -317,6 +321,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
retirementResigns = retirementResigns
.Where(x => x.rootDnaOldId == nodeId).ToList();
}
else if (role == "PARENT")
{
retirementResigns = retirementResigns
.Where(x => x.child1DnaOldId == nodeId).ToList();
}
else if (role == "NORMAL")
{
retirementResigns = retirementResigns
@ -365,6 +374,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var retirementResigns = await _context.RetirementResignCancels.AsQueryable()
@ -420,6 +433,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
retirementResigns = retirementResigns
.Where(x => x.rootDnaOldId == nodeId).ToList();
}
else if (role == "PARENT")
{
retirementResigns = retirementResigns
.Where(x => x.child1DnaOldId == nodeId).ToList();
}
else if (role == "NORMAL")
{
retirementResigns = retirementResigns
@ -2131,6 +2149,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var data = await _context.RetirementQuestions.AsQueryable()
@ -2180,6 +2202,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
data = data
.Where(x => x.rootDnaId == nodeId).ToList();
}
else if (role == "PARENT")
{
data = data
.Where(x => x.child1DnaId == nodeId).ToList();
}
else if (role == "NORMAL")
{
data = data

View file

@ -200,6 +200,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var retirementResignEmployees = await _context.RetirementResignEmployees.AsQueryable()
@ -256,6 +260,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
retirementResignEmployees = retirementResignEmployees
.Where(x => x.rootDnaOldId == nodeId).ToList();
}
else if (role == "PARENT")
{
retirementResignEmployees = retirementResignEmployees
.Where(x => x.child1DnaOldId == nodeId).ToList();
}
else if (role == "NORMAL")
{
retirementResignEmployees = retirementResignEmployees
@ -304,6 +313,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var retirementResignEmployees = await _context.RetirementResignEmployeeCancels.AsQueryable()
@ -358,6 +372,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
retirementResignEmployees = retirementResignEmployees
.Where(x => x.rootDnaOldId == nodeId).ToList();
}
else if (role == "PARENT")
{
retirementResignEmployees = retirementResignEmployees
.Where(x => x.child1DnaOldId == nodeId).ToList();
}
else if (role == "NORMAL")
{
retirementResignEmployees = retirementResignEmployees
@ -2047,6 +2066,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
nodeId = profileAdmin?.RootDnaId;
}
else if (role == "PARENT")
{
nodeId = profileAdmin?.Child1DnaId;
}
var node = profileAdmin?.Node;
var data = await _context.RetirementEmployeeQuestions.AsQueryable()
@ -2096,6 +2119,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
data = data
.Where(x => x.rootDnaId == nodeId).ToList();
}
else if (role == "PARENT")
{
data = data
.Where(x => x.child1DnaId == nodeId).ToList();
}
else if (role == "NORMAL")
{
data = data