add parent
This commit is contained in:
parent
ddf899ce5d
commit
9e8fe1b30a
22 changed files with 289 additions and 122 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue