diff --git a/CompanyManagment.EFCore/Repository/LeaveRepository.cs b/CompanyManagment.EFCore/Repository/LeaveRepository.cs index f6f72f16..8de3bd39 100644 --- a/CompanyManagment.EFCore/Repository/LeaveRepository.cs +++ b/CompanyManagment.EFCore/Repository/LeaveRepository.cs @@ -305,6 +305,11 @@ public class LeaveRepository : RepositoryBase, ILeaveRepository if (searchModel.LeaveType == "sickLeave") leaveMainList = leaveMainList.Where(x => x.LeaveType == "استعلاجی"); + if (searchModel.IsInvalid) + { + leaveMainList = leaveMainList.IgnoreQueryFilters().Where(x => x.IsInvalid); + } + if (!string.IsNullOrWhiteSpace(searchModel.StartLeave) && !string.IsNullOrWhiteSpace(searchModel.EndLeave)) { var start = searchModel.StartLeave.ToGeorgianDateTime(); @@ -341,6 +346,7 @@ public class LeaveRepository : RepositoryBase, ILeaveRepository Month = item.Month, MonthStr = item.Month.ToFarsiMonthByIntNumber(), CreationDate = item.CreationDate, + IsInvalid = item.IsInvalid }).OrderByDescending(x => x.CreationDate).Skip(searchModel.PageIndex).Take(30).ToList(); return leaveList; diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml index d1a2e273..e5a8326c 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml @@ -252,6 +252,8 @@ + +
@@ -260,66 +262,80 @@
-
+ @{ + var gridCols = Model.HasCustomizeCheckout ? "4" : "3"; + } +
- - - - -
+ + + + + @if (Model.HasCustomizeCheckout) + { + + } +
+
-
-
- -
+
+ +
+ +
+ +
تاریخ شروع @@ -1221,6 +1244,12 @@ $('#sendDropdownMonth').val(dataVal); }); + $('.dropdown-invalid .item').on("click", function () { + let dataVal = $(this).attr("value-data-invalid"); + $('#sendDropdownInvalid').val(dataVal === 'both' ? '' : dataVal); + $('#isInvalid').val(dataVal === 'both' ? '' : dataVal) + }); + var sendDropdownNormal = $("#sendSorting").val(); if (sendDropdownNormal) { let itemDropdownNormal = $(".dropdown-normal").find(".item[value-data-normal='" + sendDropdownNormal + "']"); @@ -1245,6 +1274,21 @@ selectedMonthDisplay.text(itemDropdownMonth.text()); } + // Initialize invalid dropdown display + var sendDropdownInvalid = $("#sendDropdownInvalid").val(); + if (!sendDropdownInvalid) { + let itemInvalidBoth = $(".dropdown-invalid").find(".item[value-data-invalid='both']"); + itemInvalidBoth.addClass("active"); + var selectedInvalidDisplay = $(".wrapper-dropdown-invalid").find(".selected-display"); + selectedInvalidDisplay.text(itemInvalidBoth.text()); + } else { + let invalidVal = sendDropdownInvalid.toString().toLowerCase(); + let itemInvalid = $(".dropdown-invalid").find(".item[value-data-invalid='" + invalidVal + "']"); + itemInvalid.addClass("active"); + var selectedInvalidDisplay = $(".wrapper-dropdown-invalid").find(".selected-display"); + selectedInvalidDisplay.text(itemInvalid.text()); + } + // check if anything else ofther than the dropdown is clicked window.addEventListener("click", function (e) { if (e.target.closest(".wrapper-dropdown") === null) { @@ -2754,7 +2798,8 @@ 'searchModel.LeaveType': $('#leaveType').val(), 'searchModel.StartLeave': $('#start').val(), 'searchModel.EndLeave': $('#end').val(), - 'searchModel.PageIndex': $('#pageIndex').val() + 'searchModel.PageIndex': $('#pageIndex').val(), + 'searchModel.IsInvalid': $('#isInvalid').val(), }; diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml.cs index 3ed5f062..4e5867a3 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml.cs @@ -54,8 +54,9 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees private readonly IHolidayItemApplication _holidayItemApplication; private readonly IRollCallServiceApplication _rollCallServiceApplication; public int PageIndex; + public bool HasCustomizeCheckout { get; set; } - #region Initial Data + #region Initial Data public LeaveModel(IWorkshopApplication workshopApplication, IEmployeeApplication employeeApplication, IAuthHelper authHelper, ILeaveApplication leaveApplication, IYearlySalaryApplication yearlySalaryApplication, IPasswordHasher passwordHasher, IHttpContextAccessor contextAccessor, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IHolidayItemApplication holidayItemApplication, IRollCallServiceApplication rollCallServiceApplication) { _workshopApplication = workshopApplication; @@ -86,6 +87,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees { //long employeeId = _passwordHasher.SlugDecrypt(employeeHash); long employeeId = searchModel.EmployeeId; + var rollCallServiceViewModel = _rollCallServiceApplication.GetActiveServiceByWorkshopId(_workshopId); + HasCustomizeCheckout = rollCallServiceViewModel is { HasCustomizeCheckoutService: "true" }; if (employeeId >= 0) { var workshop = _workshopApplication.GetDetails(_workshopId); @@ -97,7 +100,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees Year = searchModel.Year, Month = searchModel.Month, StartLeave = searchModel.StartLeave, - EndLeave = searchModel.EndLeave + EndLeave = searchModel.EndLeave, + IsInvalid = searchModel.IsInvalid }; Year = searchModel.Year; Month = searchModel.Month; diff --git a/ServiceHost/wwwroot/AssetsClient/js/dropdown.js b/ServiceHost/wwwroot/AssetsClient/js/dropdown.js index afa5ae18..edcfe3e4 100644 --- a/ServiceHost/wwwroot/AssetsClient/js/dropdown.js +++ b/ServiceHost/wwwroot/AssetsClient/js/dropdown.js @@ -215,6 +215,58 @@ $(document).ready(function () { }); } + /* --------------------------------------------------------------------------------Invalid-------------------------------------------------------------------------------------- */ + + // dropdown invalid + const selectedAllInvalid = document.querySelectorAll(".wrapper-dropdown-invalid"); + + selectedAllInvalid.forEach((selected) => { + const optionsContainer = selected.children[2]; + const optionsList = selected.querySelectorAll("div.wrapper-dropdown-invalid li"); + + selected.addEventListener("click", () => { + let arrow = selected.children[1]; + + let currentActive = document.querySelector(".wrapper-dropdown-invalid.active"); + + if (currentActive) { + let anotherArrow = currentActive.children[1]; + handleDropdown(currentActive, anotherArrow, false); + } + + handleDropdown(selected, arrow, true); + }); + + // update the display of the dropdown invalid + for (let o of optionsList) { + o.addEventListener("click", () => { + selected.querySelector(".selected-display").innerHTML = o.innerHTML; + }); + } + + $(document).on("click", '.dropdown-invalid .item', function (e) { + $('.dropdown-invalid .item').removeClass("active"); + $(this).addClass("active"); + closeAllDropdownsInvalid(); + }); + }); + + // check if anything else other than the dropdown invalid is clicked + window.addEventListener("click", function (e) { + if (e.target.closest(".wrapper-dropdown-invalid") === null) { + closeAllDropdownsInvalid(); + } + }); + + // close all the dropdowns invalid + function closeAllDropdownsInvalid() { + const selectedInvalid = document.querySelectorAll(".wrapper-dropdown-invalid"); + selectedInvalid.forEach((selected) => { + const optionsContainer = selected.children[2]; + let arrow = selected.children[1]; + handleDropdown(selected, arrow, false); + }); + } // open all the dropdowns function handleDropdown(dropdown, arrow, open) {