From f6b6dfa0468840b4ccb3e25cce9011ab527f08a3 Mon Sep 17 00:00:00 2001 From: Mahan Ch Date: Sun, 8 Jun 2025 16:04:54 +0330 Subject: [PATCH] merge from team work --- .../IInsuranceListRepository.cs | 4 +- .../IInsuranceListApplication.cs | 4 +- .../InsuranceListApplication.cs | 4 +- .../Repository/InsuranceListRepository.cs | 125 +- .../Pages/Company/InsuranceList/Index.cshtml | 546 +-------- .../Company/InsuranceList/Index.cshtml.cs | 8 +- .../page/InsuranceList/js/Index.js | 377 +++++- ServiceHost/wwwroot/AssetsTailwind/main.css | 1042 +---------------- 8 files changed, 500 insertions(+), 1610 deletions(-) diff --git a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs index f7a1b777..1ff57039 100644 --- a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs +++ b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs @@ -64,9 +64,9 @@ public interface IInsuranceListRepository:IRepository #region Mahan Task GetInsuranceOperationDetails(long id); - Task GetTabCounts(long accountId,int month,int year); + Task GetTabCounts(InsuranceListSearchModel searchModel); - #endregion + #endregion } diff --git a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs index fc91ef9f..a93637cb 100644 --- a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs +++ b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs @@ -44,7 +44,7 @@ public interface IInsuranceListApplication Task ConfirmInsuranceOperation(InsuranceListConfirmOperation command); Task GetInsuranceOperationDetails(long id); - Task GetTabCounts(long accountId, int month, int year); + Task GetTabCounts(InsuranceListSearchModel searchModel); - #endregion + #endregion } \ No newline at end of file diff --git a/CompanyManagment.Application/InsuranceListApplication.cs b/CompanyManagment.Application/InsuranceListApplication.cs index a0583057..6de0b466 100644 --- a/CompanyManagment.Application/InsuranceListApplication.cs +++ b/CompanyManagment.Application/InsuranceListApplication.cs @@ -2329,9 +2329,9 @@ public class InsuranceListApplication : IInsuranceListApplication return _insuranceListRepositpry.GetInsuranceOperationDetails(id); } - public Task GetTabCounts(long accountId, int month, int year) + public Task GetTabCounts(InsuranceListSearchModel searchModel) { - return _insuranceListRepositpry.GetTabCounts(accountId, month, year); + return _insuranceListRepositpry.GetTabCounts(searchModel); } #endregion diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index d8e70d3d..5abd22c0 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -1492,33 +1492,108 @@ public class InsuranceListRepository : RepositoryBase, IIns return res.ToList(); } - public async Task GetTabCounts(long accountId, int month, int year) - { - var workshopIds = _context.WorkshopAccounts - .Where(a => a.AccountId == accountId) - .Select(a => a.WorkshopId); - var res = await _context.InsuranceListSet - .Where(x => - x.Year == year.ToString("0000") && - x.Month == month.ToString("00") && - workshopIds.Contains(x.WorkshopId) - ) - .GroupBy(x => 1) - .Select(g => new InsuranceListTabsCountViewModel - { - NotStarted = g.Count(x => - !x.Debt.IsDone && !x.EmployerApproval.IsDone && !x.Inspection.IsDone && !x.ConfirmSentlist), - InProgress = g.Count(x => - (x.Debt.IsDone || x.EmployerApproval.IsDone || x.Inspection.IsDone)&& !(x.Debt.IsDone && x.EmployerApproval.IsDone && x.Inspection.IsDone) && !x.ConfirmSentlist), - ReadyToSendList = g.Count(x => - x.Debt.IsDone && x.EmployerApproval.IsDone && x.Inspection.IsDone && !x.ConfirmSentlist), - Done = g.Count(x => x.ConfirmSentlist) - }) - .FirstOrDefaultAsync() ?? new InsuranceListTabsCountViewModel(); + public async Task GetTabCounts(InsuranceListSearchModel searchModel) + { + var acountId = _authHelper.CurrentAccountId(); - return res; + var workshopIds = _context.WorkshopAccounts + .Where(a => a.AccountId == acountId) + .Select(a => a.WorkshopId); + var query = _context.InsuranceListSet + .Where(x => workshopIds.Contains(x.WorkshopId)) + .Join(_context.Workshops.Include(x => x.InsuranceWorkshopInfo), + insurance => insurance.WorkshopId, + workshop => workshop.id, + (insurance, workshop) => new { insurance, workshop }) + .GroupJoin(_context.WorkshopEmployers, + result => result.workshop.id, + employer => employer.WorkshopId, + (result, employer) => new { result.insurance, result.workshop, employer }) + .Select(result => new InsuranceListViewModel + { + Id = result.insurance.id, + Year = result.insurance.Year, + Month = result.insurance.Month, + WorkShopId = result.insurance.WorkshopId, + WorkShopCode = result.workshop.InsuranceWorkshopInfo != null ? result.workshop.InsuranceWorkshopInfo.InsuranceCode : result.workshop.InsuranceCode, + WorkShopName = result.workshop.InsuranceWorkshopInfo != null ? result.workshop.InsuranceWorkshopInfo.WorkshopName : result.workshop.WorkshopFullName, + TypeOfInsuranceSend = result.workshop.TypeOfInsuranceSend == "NormalList" ? "عادی" : + result.workshop.TypeOfInsuranceSend == "Govermentlist" ? "کمک دولت" : + result.workshop.TypeOfInsuranceSend == "Familylist" ? "خانوادگی" : "", + FixedSalary = result.workshop.FixedSalary, + EmployerName = result.workshop.InsuranceWorkshopInfo != null ? result.workshop.InsuranceWorkshopInfo.EmployerName : result.workshop.WorkshopFullName, + ConfirmSentlist = result.insurance.ConfirmSentlist, + EmployerId = result.employer.First().EmployerId, + DebtDone = result.insurance.Debt.IsDone, + EmployerApproved = result.insurance.EmployerApproval.IsDone, + InspectionDone = result.insurance.Inspection.IsDone + }); - } + if (!string.IsNullOrEmpty(searchModel.Year) && searchModel.Year != "0" && !string.IsNullOrEmpty(searchModel.Month) && searchModel.Month != "0") + query = query.Where(x => x.Year == searchModel.Year && x.Month == searchModel.Month); + else + { + if (!string.IsNullOrEmpty(searchModel.Month) && searchModel.Month != "0") + query = query.Where(x => x.Month == searchModel.Month); + + if (!string.IsNullOrEmpty(searchModel.Year) && searchModel.Year != "0") + query = query.Where(x => x.Year == searchModel.Year); + + } + if (!string.IsNullOrEmpty(searchModel.WorkShopCode)) + query = query.Where(x => x.WorkShopCode == searchModel.WorkShopCode); + + if (!string.IsNullOrEmpty(searchModel.WorkShopName)) + query = query.Where(x => x.WorkShopName.Contains(searchModel.WorkShopName)); + + + if (searchModel.WorkshopId > 0) + { + var workshopName = query.FirstOrDefault(u => u.WorkShopId == searchModel.WorkshopId)?.WorkShopName; + + query = query.Where(x => x.WorkShopName.Contains(workshopName)); + } + + if (searchModel.EmployerId > 0) + { + var employerName = query.FirstOrDefault(u => u.EmployerId == searchModel.EmployerId)?.EmployerName; + query = query.Where(x => x.EmployerName.Contains(employerName)); + } + + if (!string.IsNullOrEmpty(searchModel.EmployerName)) + query = query.Where(x => x.EmployerName.Contains(searchModel.EmployerName)); + + + if (searchModel.FixedSalary != null) + query = query.Where(x => x.FixedSalary == searchModel.FixedSalary); + + if (!string.IsNullOrEmpty(searchModel.TypeOfInsuranceSend) && searchModel.TypeOfInsuranceSend != "0") + query = query.Where(x => x.TypeOfInsuranceSend == searchModel.TypeOfInsuranceSend); + + if (!string.IsNullOrEmpty(searchModel.City) && searchModel.City != "0") + query = query.Where(x => x.City == searchModel.City); + + if (!string.IsNullOrEmpty(searchModel.Branch)) + query = query.Where(x => x.Branch.Contains(searchModel.Branch)); + + + + var res = await query.GroupBy(x => 1) + .Select(g => new InsuranceListTabsCountViewModel + { + NotStarted = g.Count(x => + !x.DebtDone && !x.EmployerApproved && !x.InspectionDone && !x.ConfirmSentlist), + InProgress = g.Count(x => + (x.DebtDone || x.EmployerApproved || x.InspectionDone) && !(x.DebtDone && x.EmployerApproved && x.InspectionDone) && !x.ConfirmSentlist), + ReadyToSendList = g.Count(x => + x.DebtDone && x.EmployerApproved && x.InspectionDone && !x.ConfirmSentlist), + Done = g.Count(x => x.ConfirmSentlist) + }) + .FirstOrDefaultAsync() ?? new InsuranceListTabsCountViewModel(); + + return res; + + } /// /// diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml index c7d4c9f3..78f329c3 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml @@ -156,7 +156,7 @@
- + @@ -224,17 +224,17 @@
-
+@*
-
+
*@ -
+@*
-
+
*@
@@ -247,7 +247,7 @@
- - - - @@ -568,6 +399,7 @@
+
@@ -647,19 +479,19 @@
-
+@*
-
+
*@ -
+@*
-
+
*@
@@ -711,6 +543,8 @@ var insuranceConfirmUrl = `#showmodal=@Url.Page("/Company/InsuranceList/Index", "InsuranceConfirm")`; var downloadFileUrl = `@Url.Page("/Company/InsuranceList/Index", "DownloadFile")`; var removeInsuranceListUrl = `@Url.Page("/Company/InsuranceList/Index", "RemoveInsuranceList")`; + var workshopNameUrl = `@Url.Page("/Company/InsuranceList/Index", "WorkshopName")`; + var employerNameUrl = `@Url.Page("/Company/InsuranceList/Index", "EmployerName")`; var currentAccountId = Number(@currentAccount.RoleId); var month = '@Model.BeforCurrentMonth_'; @@ -722,338 +556,14 @@ var hasPermission_80214 = @(permissionList.Contains(80214) ? "true" : "false"); var hasPermission_80215 = @(permissionList.Contains(80215) ? "true" : "false"); var hasPermission_80216 = @(permissionList.Contains(80216) ? "true" : "false"); - //new Permission - var hasPermission_80217 = true; + + var permissions = { + 80217: @permissionList.Contains(80217).ToString().ToLower(), + 80218: @permissionList.Contains(80218).ToString().ToLower(), + 80219: @permissionList.Contains(80219).ToString().ToLower(), + 80220: @permissionList.Contains(80220).ToString().ToLower() + }; -} - - - - - +} \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs index 9a8aba78..d69a0c8c 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs @@ -1098,8 +1098,12 @@ public class IndexModel : PageModel public async Task OnGetTabCounts(int month, int year) { - var accountId = _authHelper.CurrentAccountId(); - var resultData = await _insuranceListApplication.GetTabCounts(accountId, month, year); + var searchModel = new InsuranceListSearchModel() + { + Year = year.ToString("0000"), + Month = month.ToString("00") + }; + var resultData = await _insuranceListApplication.GetTabCounts(searchModel); return new JsonResult(new { diff --git a/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js b/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js index c5f9657a..3a16fbaa 100644 --- a/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js +++ b/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js @@ -1,4 +1,5 @@ var pageIndexJs = 0; +var hasMoreData = true; var isMobile = window.matchMedia('(max-width: 768px)').matches; var overlay = document.querySelector('.offcanvas-overlay'); @@ -41,21 +42,21 @@ $(document).ready(function () { "workshop-id", "workshop-name", "type-of-insurance", - "branch", - "city", + //"branch", + //"city", "fixed-salary" ]); - paramsUrl['year'] !== "" && $("#searchModel_Year").val(paramsUrl['year']).trigger("change"); - paramsUrl['month'] !== "" && $("#searchModel_Month").val(paramsUrl['month']).trigger("change"); + paramsUrl['year'] !== "" ? $("#searchModel_Year").val(paramsUrl['year']).trigger("change") : $("#searchModel_Year").val(year).trigger("change"); + paramsUrl['month'] !== "" ? $("#searchModel_Month").val(paramsUrl['month']).trigger("change") : $("#searchModel_Month").val(month).trigger("change"); $("#searchModel_WorkShopCode").val(paramsUrl['workshop-code']); $("#searchModel_EmployerId").val(paramsUrl['employee-id']); paramsUrl['employee-id'] !== "" && $("#empSearchEmployer").val(paramsUrl['employee-name']).addClass('selectedOption'); $("#searchModel_WorkshopId").val(paramsUrl['workshop-id']); paramsUrl['workshop-id'] !== "" && $("#empSearchWorkshop").val(paramsUrl['workshop-name']).addClass('selectedOption'); paramsUrl['type-of-insurance'] === "" ? $("#searchModel_TypeOfInsuranceSend").val("0").trigger("change") : $("#searchModel_TypeOfInsuranceSend").val(paramsUrl['type-of-insurance']).trigger("change"); - $("#searchModel_Branch").val(paramsUrl['branch']); - paramsUrl['fixed-salary'] === "" ? $("#searchModel_City").val(0).trigger("change") : $("#searchModel_City").val(paramsUrl['city']).trigger("change"); + //$("#searchModel_Branch").val(paramsUrl['branch']); + //paramsUrl['city'] === "" ? $("#searchModel_City").val(0).trigger("change") : $("#searchModel_City").val(paramsUrl['city']).trigger("change"); paramsUrl['fixed-salary'] === "" ? $("#searchModel_FixedSalary").val(0).trigger("change") : $("#searchModel_FixedSalary").val(paramsUrl['fixed-salary']).trigger("change"); var isAnyNotEmpty = false; @@ -99,6 +100,7 @@ $(document).ready(function () { var statusValue = $(this).prop('value'); pageIndexJs = 0; + hasMoreData = true; $("#load-data-html-mobile").html(''); $('#load-data-html').html(''); @@ -129,8 +131,8 @@ $(document).ready(function () { .addParam("workshop-id", $("#searchModel_WorkshopId").val() === "0" ? "" : $("#searchModel_WorkshopId").val()) .addParam("workshop-name", $("#empSearchWorkshop").val()) .addParam("type-of-insurance", $("#searchModel_TypeOfInsuranceSend").val()) - .addParam("branch", $("#searchModel_Branch").val()) - .addParam("city", $("#searchModel_City").val()) + //.addParam("branch", $("#searchModel_Branch").val()) + //.addParam("city", $("#searchModel_City").val()) .addParam("fixed-salary", $("#searchModel_FixedSalary").val()) .pushState(); @@ -138,6 +140,7 @@ $(document).ready(function () { var activeValue = $activeTab.val(); pageIndexJs = 0; + hasMoreData = true; $("#load-data-html-mobile").html(''); $('#load-data-html').html(''); loadGetTabCounts(); @@ -146,8 +149,27 @@ $(document).ready(function () { $('.btn-clear-filter').removeClass('disable'); }); + $('#closeModal').click(function () { + $('#MainModal').modal('hide'); + }); + loadGetTabCounts(); - loadSearchNew(); + //loadSearchNew(); + // Active Tabs by Permission and Load Search New Function + let found = false; + $(".tab-bar__tab").removeClass("tab-bar__tab--active"); + $(".tab-bar__tab").each(function () { + var permission = $(this).data("permission"); + + if (!found && permissions[permission] === true || permissions[permission] === "true") { + $(this).addClass("tab-bar__tab--active"); + + var status = parseInt($(this).val()); + loadSearchNew(status); + + found = true; + } + }); }); function removeSearch() { @@ -213,8 +235,8 @@ function loadSearchNew(status = 0) { "employee-id", "workshop-id", "type-of-insurance", - "branch", - "city", + //"branch", + //"city", "fixed-salary" ]); @@ -225,8 +247,8 @@ function loadSearchNew(status = 0) { EmployerId: paramsUrl['employee-id'], WorkshopId: paramsUrl['workshop-id'], TypeOfInsuranceSend: paramsUrl['type-of-insurance'], - Branch: paramsUrl['branch'], - City: paramsUrl['city'], + //Branch: paramsUrl['branch'], + //City: paramsUrl['city'], FixedSalary: paramsUrl['fixed-salary'], Status: status, PageIndex: pageIndex @@ -234,7 +256,7 @@ function loadSearchNew(status = 0) { var b = pageIndexJs % 30; - if (b === 0) { + if (b === 0 && hasMoreData) { ajaxService.get(ajaxSearchNewUrl, searchModel, false) .then(response => { @@ -435,16 +457,20 @@ function loadSearchNew(status = 0) { pageIndexJs++; }); } else { - const emptyHtml = ` + var emptyHtml = ``; + if (pageIndexJs === responseData.length) { + emptyHtml = `
اطلاعاتی وجود ندارد.
`; + } html += emptyHtml; htmlMobile += emptyHtml; + hasMoreData = false; } $("#load-data-html").append(html); @@ -461,7 +487,7 @@ function generateButtons(item, pathDSKKAR00, pathDSKWOR00) { var isDisabled = item.isBlockCantracingParty === 'true' ? 'disable' : ''; // Operations Button - if (hasPermission_80217) { + if (hasPermission_80212) { html += `