From c561a138d63f199e91f3951b05abd2c32df94cc2 Mon Sep 17 00:00:00 2001 From: MahanCh Date: Wed, 9 Apr 2025 18:38:15 +0330 Subject: [PATCH] add early exit --- .../RollCall/RollCallTimeViewModel.cs | 2 + .../Repository/RollCallRepository.cs | 41 +- .../Client/Pages/Shared/_ClientLayout.cshtml | 17 +- .../wwwroot/AssetsClient/css/sidebar-menu.css | 600 ++++++++++++++++++ 4 files changed, 634 insertions(+), 26 deletions(-) create mode 100644 ServiceHost/wwwroot/AssetsClient/css/sidebar-menu.css diff --git a/CompanyManagment.App.Contracts/RollCall/RollCallTimeViewModel.cs b/CompanyManagment.App.Contracts/RollCall/RollCallTimeViewModel.cs index d6debff5..fb161d22 100644 --- a/CompanyManagment.App.Contracts/RollCall/RollCallTimeViewModel.cs +++ b/CompanyManagment.App.Contracts/RollCall/RollCallTimeViewModel.cs @@ -9,4 +9,6 @@ public class RollCallTimeViewModel public TimeSpan TotalHours { get; set; } public DateTime StartDateGr { get; set; } public DateTime EndDateGr { get; set; } + public string EntryTimeDifferences { get; set; } + public string ExitTimeDifferences { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/RollCallRepository.cs b/CompanyManagment.EFCore/Repository/RollCallRepository.cs index 5ec6d2a5..1986a106 100644 --- a/CompanyManagment.EFCore/Repository/RollCallRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallRepository.cs @@ -528,9 +528,9 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos if (employeeRollCallStatuses == null || employeeRollCallStatuses.EmployeesStatus == null || !employeeRollCallStatuses.EmployeesStatus.Any()) return new(); - //this list will have all the months which employee was active in, remember this doesn't have statuses, - //just the list of months which user had activity in - var activeMonths = new List(); + //this list will have all the months which employee was active in, remember this doesn't have statuses, + //just the list of months which user had activity in + var activeMonths = new List(); //filling the list foreach (var status in employeeRollCallStatuses.EmployeesStatus) @@ -562,10 +562,10 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos //get the months that include these dates activeMonthsList = activeMonthsList.Where(x => x.Year >= startSearch.Year && x.Month >= startSearch.Month && x.Year <= endSearch.Year && x.Month <= endSearch.Month).ToList(); } - //if exact datetime is given start and end will be the same date + //if exact datetime is given start and end will be the same date if (exactDateTime.HasValue) { - startSearch = new PersianDateTime(exactDateTime.Value); + startSearch = new PersianDateTime(exactDateTime.Value); endSearch = startSearch; activeMonthsList = activeMonthsList.Where(x => x.Year >= startSearch.Year && x.Month >= startSearch.Month && x.Year <= endSearch.Year && x.Month <= endSearch.Month).ToList(); } @@ -575,8 +575,8 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos { var persianDateIndex = new PersianDateTime(dateIndex.Value); - //gets first of month, if the day is 21st of month, first of month is 21-21 +1 = 1 or 21 + (-(21-1)) = 1 - var dateIndexFirstOfMonth = persianDateIndex.AddDays(-(persianDateIndex.Day - 1)); + //gets first of month, if the day is 21st of month, first of month is 21-21 +1 = 1 or 21 + (-(21-1)) = 1 + var dateIndexFirstOfMonth = persianDateIndex.AddDays(-(persianDateIndex.Day - 1)); activeMonthsList = activeMonthsList.Where(x => dateIndexFirstOfMonth >= x).ToList(); } @@ -594,7 +594,7 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos x.StartDate < nextMonthFirstDay); - //get leaves in the specified month + //get leaves in the specified month var leavesQuery = _context.LeaveList.Where(x => (x.LeaveType == "استعلاجی" || (x.LeaveType == "استحقاقی" && x.PaidLeaveType == "روزانه")) && x.IsAccepted && @@ -653,7 +653,9 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos StartDate = y.StartDate.Value.ToString("HH:mm"), EndDate = y.EndDate!.Value.ToString("HH:mm"), StartDateGr = y.StartDate.Value, - EndDateGr = y.EndDate.Value + EndDateGr = y.EndDate.Value, + EntryTimeDifferences = CalculateEntryTimeDifferences(y.EarlyEntryDuration, y.LateEntryDuration), + ExitTimeDifferences = CalculateExitTimeDifferences(y.EarlyExitDuration, y.LateExitDuration) }), TotalWorkingHoursSpan = new TimeSpan(rollCallsList.Where(y => x.Date == y.ShiftDate.Date) .Sum(y => (y.EndDate!.Value - y.StartDate.Value).Ticks)), @@ -662,26 +664,26 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos }; }); - //filling TotalWorkingHours string from TimeSpans we filled in the last step and other info - result = result.Select(x => new RollCallViewModel() + //filling TotalWorkingHours string from TimeSpans we filled in the last step and other info + result = result.Select(x => new RollCallViewModel() { EmployeeFullName = employeeName.EmployeeFullName, EmployeeId = employeeId, PersonnelCode = personnelCode.ToString(), DateGr = x.DateGr, DateFa = x.DateFa, - + DayOfWeekFa = x.DateGr.DayOfWeek.DayOfWeeKToPersian(), IsHoliday = _holidayItemApplication.IsHoliday(x.DateGr), IsAbsent = !x.RollCallTimesList.Any(), - RollCallTimesList = x.RollCallTimesList.OrderBy(r=>r.StartDateGr), + RollCallTimesList = x.RollCallTimesList.OrderBy(r => r.StartDateGr), HasLeave = x.HasLeave, TotalWorkingHoursSpan = x.TotalWorkingHoursSpan, TotalWorkingHours = $"{(int)x.TotalWorkingHoursSpan.TotalHours}:{x.TotalWorkingHoursSpan.Minutes.ToString("00")}" }).ToList(); //total working hours in the whole month or duration - var totalWorkingHours = new TimeSpan(result.Sum(x => x.TotalWorkingHoursSpan.Ticks)); + var totalWorkingHours = new TimeSpan(result.Sum(x => x.TotalWorkingHoursSpan.Ticks)); //if there are any other months available that the selector return new EmployeeRollCallsByMonthViewModel() @@ -847,10 +849,12 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos EmployeeFullName = x.EmployeeFullName, EmployeeId = x.EmployeeId, Reason = leave == null ? "" : $"{leave.LeaveType}-{leave.PaidLeaveType}", - RollCallTimesList = employeeRollCallsForDate.OrderBy(r=>r.StartDate).Select(y => new RollCallTimeViewModel() + RollCallTimesList = employeeRollCallsForDate.OrderBy(r => r.StartDate).Select(y => new RollCallTimeViewModel() { EndDate = y.EndDate!.Value.ToString("HH:mm"), StartDate = y.StartDate!.Value.ToString("HH:mm"), + EntryTimeDifferences = CalculateEntryTimeDifferences(y.EarlyEntryDuration, y.LateEntryDuration), + ExitTimeDifferences = CalculateExitTimeDifferences(y.EarlyExitDuration, y.LateExitDuration) }), HasLeave = leave != null, IsAbsent = !employeeRollCallsForDate.Any(), @@ -1081,10 +1085,13 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos EmployeeFullName = nameReferences.FirstOrDefault(y => x.Key == y.EmployeeId).EmployeeFullName, EmployeeId = x.FirstOrDefault()!.EmployeeId, TotalWorkingHoursSpan = new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => (y.EndDate!.Value - y.StartDate!.Value).Ticks)), - RollCallTimesList = x.Select(y => new RollCallTimeViewModel() + RollCallTimesList = x.OrderBy(r => r.StartDate).Select(y => new RollCallTimeViewModel() { StartDate = y.StartDate!.Value.ToString("HH:mm"), - EndDate = y.EndDate?.ToString("HH:mm") + EndDate = y.EndDate?.ToString("HH:mm"), + EntryTimeDifferences = CalculateEntryTimeDifferences(y.EarlyEntryDuration, y.LateEntryDuration), + ExitTimeDifferences = CalculateExitTimeDifferences(y.EarlyExitDuration, y.LateExitDuration) + }).ToList() diff --git a/ServiceHost/Areas/Client/Pages/Shared/_ClientLayout.cshtml b/ServiceHost/Areas/Client/Pages/Shared/_ClientLayout.cshtml index 30dd7aad..758d5549 100644 --- a/ServiceHost/Areas/Client/Pages/Shared/_ClientLayout.cshtml +++ b/ServiceHost/Areas/Client/Pages/Shared/_ClientLayout.cshtml @@ -2,19 +2,16 @@ @using Microsoft.AspNetCore.Mvc.TagHelpers @using Microsoft.AspNetCore.Razor.Language.Intermediate @using WorkFlow.Application.Contracts.WorkFlow -@using Version = _0_Framework.Application.Version @inject _0_Framework.Application.IAuthHelper AuthHelper; @inject IWorkFlowApplication WorkFlowApplication; @{ + string clientVersion = _0_Framework.Application.Version.StyleVersion; var currentAccount = AuthHelper.CurrentAccountInfo(); - long workshopId = currentAccount.WorkshopList.First(x => x.Slug == currentAccount.WorkshopSlug).Id; - - int countWorkFlow = 0;/* await WorkFlowApplication.GetCountAllWorkFlows(workshopId); */ - + int countWorkFlow = 0;/* await WorkFlowApplication.GetCountAllWorkFlows(workshopId); */ var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()) { { "countWorkFlow", countWorkFlow } }; } @@ -45,6 +42,7 @@ + @@ -60,8 +58,8 @@
- - + + @@ -84,6 +82,7 @@ + @@ -404,9 +403,9 @@ - + @RenderSection("Script", false) - +