From ee0f853a85e17775fdfff149de9fdb25caa38b43 Mon Sep 17 00:00:00 2001 From: rowell_m_soriano Date: Tue, 17 Mar 2026 07:11:17 +0800 Subject: [PATCH] Fixing Qty submission in Item Cart and adding Item no searching in item management --- CPRNIMS.Domain/Contracts/Items/IItem.cs | 2 +- CPRNIMS.Domain/Contracts/PR/IPRequest.cs | 12 +- CPRNIMS.Domain/Services/Items/Item.cs | 64 ++- CPRNIMS.Domain/Services/PR/PRequest.cs | 366 ++++++++++++++++-- CPRNIMS.Domain/UIContracts/Items/IItem.cs | 3 +- CPRNIMS.Domain/UIContracts/PR/IPRequest.cs | 13 +- CPRNIMS.Domain/UIServices/Items/Item.cs | 61 ++- CPRNIMS.Domain/UIServices/PR/PRequest.cs | 100 +++-- .../Database/NonInventoryDbContext.cs | 6 +- .../Dto/Items/ItemCodeDto.cs | 6 + CPRNIMS.Infrastructure/Dto/Items/ItemDto.cs | 2 + .../Dto/Items/PagedResult.cs | 18 + CPRNIMS.Infrastructure/Dto/PR/PRDto.cs | 7 + .../Entities/Purchasing/ApprovedPR.cs | 4 - .../Purchasing/{RemovedPR.cs => DeletedPR.cs} | 6 +- .../Entities/Purchasing/DetailedPRTracking.cs | 8 +- .../Entities/Purchasing/PRList.cs | 19 +- .../ViewModel/Items/ItemVM.cs | 7 + CPRNIMS.Infrastructure/ViewModel/PR/PRVM.cs | 10 + .../Controllers/Items/ItemMgmtController.cs | 2 +- .../Controllers/Items/ItemMgmtController.cs | 39 +- .../Controllers/PR/PRMgmtController.cs | 3 +- CPRNIMS.WebApps/Views/ItemMgmt/Index.cshtml | 70 ++-- .../Views/ItemMgmt/ItemCart.cshtml | 2 +- CPRNIMS.WebApps/Views/PRMgmt/Index.cshtml | 68 +++- .../Views/PRMgmt/PRTracking.cshtml | 19 +- .../Shared/PagesView/Item/_Scripts.cshtml | 4 +- .../Shared/PagesView/PR/_PRScripts.cshtml | 6 +- CPRNIMS.WebApps/appsettings.json | 3 +- .../Items/{ItemCartV3.js => ItemCartV4.js} | 31 +- .../wwwroot/JsFunctions/Items/ItemColumns.js | 12 + ...{ItemManagementV9.js => ItemManagement.js} | 83 ++-- .../{PostPutItemV4.js => PostPutItemV5.js} | 23 +- ...dPRTrackingV9.js => DetailedPRTracking.js} | 5 +- .../PR/{PRColumnV9.js => PRColumn.js} | 6 + .../JsFunctions/PR/{PRViewV9.js => PRView.js} | 37 +- ...{ExportCSVExcel.js => ExportCSVExcelV2.js} | 1 + 37 files changed, 857 insertions(+), 271 deletions(-) create mode 100644 CPRNIMS.Infrastructure/Dto/Items/PagedResult.cs rename CPRNIMS.Infrastructure/Entities/Purchasing/{RemovedPR.cs => DeletedPR.cs} (80%) rename CPRNIMS.WebApps/wwwroot/JsFunctions/Items/{ItemCartV3.js => ItemCartV4.js} (88%) create mode 100644 CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemColumns.js rename CPRNIMS.WebApps/wwwroot/JsFunctions/Items/{ItemManagementV9.js => ItemManagement.js} (57%) rename CPRNIMS.WebApps/wwwroot/JsFunctions/Items/{PostPutItemV4.js => PostPutItemV5.js} (97%) rename CPRNIMS.WebApps/wwwroot/JsFunctions/PR/{DetailedPRTrackingV9.js => DetailedPRTracking.js} (94%) rename CPRNIMS.WebApps/wwwroot/JsFunctions/PR/{PRColumnV9.js => PRColumn.js} (97%) rename CPRNIMS.WebApps/wwwroot/JsFunctions/PR/{PRViewV9.js => PRView.js} (97%) rename CPRNIMS.WebApps/wwwroot/JsFunctions/Utilities/{ExportCSVExcel.js => ExportCSVExcelV2.js} (97%) diff --git a/CPRNIMS.Domain/Contracts/Items/IItem.cs b/CPRNIMS.Domain/Contracts/Items/IItem.cs index a14ae9c..d7e0902 100644 --- a/CPRNIMS.Domain/Contracts/Items/IItem.cs +++ b/CPRNIMS.Domain/Contracts/Items/IItem.cs @@ -14,7 +14,7 @@ namespace CPRNIMS.Domain.Contracts.Items public interface IItem { Task> GetDepartment(ItemCodeDto itemCode); - Task> GetItemList(ItemCodeDto itemCode); + Task> GetItemList(ItemCodeDto itemCode); Task> GetItemCart(ItemDto itemDto); Task> GetItemDetail(ItemDto itemDto); Task> GetItemLocalization(ItemDto itemDto); diff --git a/CPRNIMS.Domain/Contracts/PR/IPRequest.cs b/CPRNIMS.Domain/Contracts/PR/IPRequest.cs index 542f112..9d5fe47 100644 --- a/CPRNIMS.Domain/Contracts/PR/IPRequest.cs +++ b/CPRNIMS.Domain/Contracts/PR/IPRequest.cs @@ -1,4 +1,5 @@ -using CPRNIMS.Infrastructure.Dto.PR; +using CPRNIMS.Infrastructure.Dto.Items; +using CPRNIMS.Infrastructure.Dto.PR; using CPRNIMS.Infrastructure.Entities.Common; using CPRNIMS.Infrastructure.Entities.Purchasing; using CPRNIMS.Infrastructure.Entities.SMTP; @@ -19,20 +20,21 @@ namespace CPRNIMS.Domain.Contracts.PR Task> GetForReceiving(PRDto PRDto); Task> GetDashBoard(PRDto PRDto); Task> GetMyPR(PRDto PRDto); - Task> GetAllPR(PRDto PRDto); + Task> GetDetailedPRTracking(PRDto PRDto); + Task> GetAllPR(PRDto PRDto); + Task> GetPRArchived(PRDto pRDto); Task> GetPRListByPRNo(PRDto PRDto); Task> GetNotifUserKey(PRDto PRDto); Task> GetPRDetailByPRNo(PRDto PRDto); Task> GetPRStatusById(PRDto PRDto); - Task> GetDetailedPRTracking(PRDto PRDto); Task> GetSupplierAlternativeOffer(PRDto PRDto); Task> GetSupplierAlterOfferDetails(PRDto PRDto); Task> GetNotificationById(PRDto PRDto); Task> GetApproverName(PRDto PRDto); Task> GetApproverNameByPRNo(PRDto PRDto); Task> GetProjectCodes(PRDto pRDto); - Task> GetRemovedPR(PRDto pRDto); - Task> GetApprovedPR(PRDto pRDto); + Task> GetDeletedPR(PRDto pRDto); + Task> GetApprovedPR(PRDto pRDto); Task PRItemRemoval(PRDto pRDto); Task PostPRApproveReject(PRDto PRDto); Task PostPutReceiving(PRDto PRDto); diff --git a/CPRNIMS.Domain/Services/Items/Item.cs b/CPRNIMS.Domain/Services/Items/Item.cs index dfb27b7..d75bedd 100644 --- a/CPRNIMS.Domain/Services/Items/Item.cs +++ b/CPRNIMS.Domain/Services/Items/Item.cs @@ -132,16 +132,66 @@ namespace CPRNIMS.Domain.Services.Items return allItems ?? new List(); } - public async Task> GetItemList(ItemCodeDto itemCode) + public async Task> GetItemList(ItemCodeDto dto) { - var allItems = await _dbContext.ItemList - .FromSqlRaw($"EXEC GetItemList @UserId", - new SqlParameter("@UserId",itemCode.UserId)) - .ToListAsync(); + var parameters = new[] + { + new SqlParameter("@UserId", dto.UserId), + new SqlParameter("@SearchItemNo", dto.SearchItemNo ?? ""), + new SqlParameter("@SearchItemName", dto.SearchItemName ?? ""), + new SqlParameter("@SearchCategory", dto.SearchCategory ?? ""), + new SqlParameter("@PageNumber", dto.PageNumber), + new SqlParameter("@PageSize", dto.PageSize) + }; - return allItems ?? new List(); + int totalCount = 0; + var items = new List(); + var categoryList = new List(); + + // Use ADO.NET to read two result sets + var conn = _dbContext.Database.GetDbConnection(); + await conn.OpenAsync(); + + using var cmd = conn.CreateCommand(); + cmd.CommandText = "EXEC GetItemList @UserId, @SearchItemNo,@SearchItemName,@SearchCategory, @PageNumber, @PageSize"; + foreach (var p in parameters) cmd.Parameters.Add(p); + cmd.CommandTimeout = 60; + + using var reader = await cmd.ExecuteReaderAsync(); + + while (await reader.ReadAsync()) + categoryList.Add(reader.GetString(0)); + + await reader.NextResultAsync(); + + if (await reader.ReadAsync()) + totalCount = reader.GetInt32(0); + + await reader.NextResultAsync(); + + while (await reader.ReadAsync()) + { + items.Add(new ItemList + { + ItemCodeId = Convert.ToInt64(reader["ItemCodeId"]), + ItemNo = Convert.ToInt64(reader["ItemNo"]), + ItemName = reader["ItemName"]?.ToString(), + ItemDescription = reader["ItemDescription"]?.ToString(), + ItemCategoryName = reader["ItemCategoryName"]?.ToString(), + CartItemCount = Convert.ToInt32(reader["CartItemCount"]) + }); + } + await conn.CloseAsync(); + + return new PagedResult + { + Data = items, + TotalCount = totalCount, + CategoryList= categoryList, + PageNumber = dto.PageNumber, + PageSize = dto.PageSize + }; } - public async Task> GetItemColor(ItemDto itemDto) { var colors = await _dbContext.ItemColors diff --git a/CPRNIMS.Domain/Services/PR/PRequest.cs b/CPRNIMS.Domain/Services/PR/PRequest.cs index 9cc6ef8..4dc50eb 100644 --- a/CPRNIMS.Domain/Services/PR/PRequest.cs +++ b/CPRNIMS.Domain/Services/PR/PRequest.cs @@ -1,5 +1,6 @@ using CPRNIMS.Domain.Contracts.PR; using CPRNIMS.Infrastructure.Database; +using CPRNIMS.Infrastructure.Dto.Items; using CPRNIMS.Infrastructure.Dto.PR; using CPRNIMS.Infrastructure.Entities.Common; using CPRNIMS.Infrastructure.Entities.Purchasing; @@ -40,31 +41,353 @@ namespace CPRNIMS.Domain.Services.PR { return await _dbContext.ProjectCodes.ToListAsync(); } - public async Task> GetRemovedPR(PRDto pRDto) + public async Task> GetDeletedPR(PRDto dto) { - var allItems = await _dbContext.RemovedPRs - .FromSqlRaw("EXEC GetRemovedPR @UserId", - new SqlParameter("@UserId", pRDto.UserId)).ToListAsync(); + var parameters = new[] + { + new SqlParameter("@UserId", dto.UserId), + new SqlParameter("@IsArchived", dto.IsArchived), + new SqlParameter("@SearchPRNo", dto.SearchPRNo ?? ""), + new SqlParameter("@SearchItemName", dto.SearchItemName ?? ""), + new SqlParameter("@SearchDept", dto.SearchDept ?? ""), + new SqlParameter("@PageNumber", dto.PageNumber), + new SqlParameter("@PageSize", dto.PageSize) + }; - return allItems ?? new List(); + int totalCount = 0; + var items = new List(); + + var conn = _dbContext.Database.GetDbConnection(); + await conn.OpenAsync(); + + using var cmd = conn.CreateCommand(); + cmd.CommandText = @"EXEC GetDeletedPR @UserId, + @SearchPRNo, @SearchItemName, @SearchDept, + @PageNumber, @PageSize"; + foreach (var p in parameters) cmd.Parameters.Add(p); + + using var reader = await cmd.ExecuteReaderAsync(); + + // First result set = total count + if (await reader.ReadAsync()) + totalCount = reader.GetInt32(0); + + // Second result set = paged rows + await reader.NextResultAsync(); + while (await reader.ReadAsync()) + { + items.Add(new DeletedPR + { + PRId = reader["PRId"] as long? ?? 0, + PRNo = reader["PRNo"] as long? ?? 0, + PRDetailsId = reader["PRDetailsId"] as long? ?? 0, + ItemNo = reader["ItemNo"] as long? ?? 0, + ItemName = reader["ItemName"]?.ToString(), + Department = reader["Department"]?.ToString(), + Remarks = reader["Remarks"]?.ToString(), + DateNeeded = reader["DateNeeded"] as DateTime? ?? DateTime.UtcNow, + CreatedDate = reader["CreatedDate"] as DateTime? ?? DateTime.UtcNow, + AttestedDate = reader["AttestedDate"]?.ToString(), + ApprovedDate = reader["ApprovedDate"]?.ToString(), + ApprovedBy = reader["ApprovedBy"]?.ToString(), + AttestedBy = reader["AttestedBy"]?.ToString(), + CreatedBy = reader["CreatedBy"]?.ToString(), + Qty = Convert.ToDecimal(reader["Qty"]) + }); + } + + await conn.CloseAsync(); + + return new PagedResult + { + Data = items, + TotalCount = totalCount, + PageNumber = dto.PageNumber, + PageSize = dto.PageSize + }; } - public async Task> GetApprovedPR(PRDto pRDto) + public async Task> GetDetailedPRTracking(PRDto dto) { - var allItems = await _dbContext.ApprovedPrs - .FromSqlRaw("EXEC GetApprovedPR @UserId", - new SqlParameter("@UserId", pRDto.UserId)).ToListAsync(); + var parameters = new[] + { + new SqlParameter("@UserId", dto.UserId), + new SqlParameter("@SearchPRNo", dto.SearchPRNo ?? ""), + new SqlParameter("@SearchItemNo", dto.SearchItemNo ?? ""), + new SqlParameter("@SearchItemName", dto.SearchItemName ?? ""), + new SqlParameter("@SearchDept", dto.SearchDept ?? ""), + new SqlParameter("@SearchStatusName", dto.SearchStatusName ?? ""), + new SqlParameter("@PageNumber", dto.PageNumber), + new SqlParameter("@PageSize", dto.PageSize) + }; - return allItems ?? new List(); + var statusList = new List(); + int totalCount = 0; + var items = new List(); + + var conn = _dbContext.Database.GetDbConnection(); + await conn.OpenAsync(); + + using var cmd = conn.CreateCommand(); + cmd.CommandText = @"EXEC GetDetailedPRTracking @UserId, + @SearchPRNo, @SearchItemNo, @SearchItemName, @SearchDept, @SearchStatusName, + @PageNumber, @PageSize"; + foreach (var p in parameters) cmd.Parameters.Add(p); + cmd.CommandTimeout = 60; + + using var reader = await cmd.ExecuteReaderAsync(); + + while (await reader.ReadAsync()) + statusList.Add(reader.GetString(0)); + + await reader.NextResultAsync(); + if (await reader.ReadAsync()) + totalCount = reader.GetInt32(0); + + await reader.NextResultAsync(); + while (await reader.ReadAsync()) + { + items.Add(new DetailedPRTracking + { + PRNo = Convert.ToInt64(reader["PRNo"]), + PRDetailsId = Convert.ToInt64(reader["PRDetailsId"]), + PRBy = reader["PRBy"]?.ToString(), + PRTypeName = reader["PRTypeName"]?.ToString(), + PRDate = reader["PRDate"] as DateTime? ?? DateTime.UtcNow, + AttestedBy = reader["AttestedBy"]?.ToString(), + ApprovedBy = reader["ApprovedBy"]?.ToString(), + CanvassDate = reader["CanvassDate"]?.ToString(), + CanvassBy = reader["CanvassBy"]?.ToString(), + CanvassNo = reader["CanvassNo"]?.ToString(), + PONo = reader["PONo"]?.ToString(), + POBy = reader["POBy"]?.ToString(), + POQty = Convert.ToDecimal(reader["POQty"]), + PODate = reader["PODate"]?.ToString(), + RRDate = reader["RRDate"]?.ToString(), + ReceivedDate = reader["ReceivedDate"]?.ToString(), + ReceivedBy = reader["ReceivedBy"]?.ToString(), + AcknowledgeBy = reader["AcknowledgeBy"]?.ToString(), + AcknowledgeDate = reader["AcknowledgeDate"]?.ToString(), + Specification = reader["Specification"]?.ToString(), + RRNo = Convert.ToInt64(reader["RRNo"]), + Department = reader["Department"]?.ToString(), + ItemCategoryName = reader["ItemCategoryName"]?.ToString(), + ItemName = reader["ItemName"]?.ToString(), + ItemDescription = reader["ItemDescription"]?.ToString(), + Status = Convert.ToInt16(reader["Status"]), + StatusName = reader["StatusName"]?.ToString(), + NewPRNo = reader["NewPRNo"]?.ToString(), + DateNeeded = reader["DateNeeded"] as DateTime? ?? DateTime.UtcNow, + ItemNo = Convert.ToInt64(reader["ItemNo"]), + Qty = Convert.ToDecimal(reader["Qty"]), + QuantityReceived = Convert.ToDecimal(reader["QuantityReceived"]), + UOMName = reader["UOMName"]?.ToString(), + ItemAttachPath = reader["ItemAttachPath"]?.ToString(), + Remarks = reader["Remarks"]?.ToString(), + }); + } + + await conn.CloseAsync(); + + return new PagedResult + { + Data = items, + TotalCount = totalCount, + PageNumber = dto.PageNumber, + PageSize = dto.PageSize, + StatusList = statusList + }; } - public async Task> GetAllPR(PRDto PRDto) + public async Task> GetApprovedPR(PRDto dto) { - var allItems = await _dbContext.PRLists - .FromSqlRaw($"EXEC GetAllPR @UserId,@IsArchived", - new SqlParameter("@UserId", PRDto.UserId), - new SqlParameter("@IsArchived", PRDto.IsArchived)) - .ToListAsync(); + var parameters = new[] + { + new SqlParameter("@UserId", dto.UserId), + new SqlParameter("@SearchPRNo", dto.SearchPRNo ?? ""), + new SqlParameter("@SearchItemName", dto.SearchItemName ?? ""), + new SqlParameter("@SearchDept", dto.SearchDept ?? ""), + new SqlParameter("@SearchStatusName", dto.SearchStatusName ?? ""), + new SqlParameter("@PageNumber", dto.PageNumber), + new SqlParameter("@PageSize", dto.PageSize) + }; - return allItems ?? new List(); + var statusList = new List(); + int totalCount = 0; + var items = new List(); + + var conn = _dbContext.Database.GetDbConnection(); + await conn.OpenAsync(); + + using var cmd = conn.CreateCommand(); + cmd.CommandText = @"EXEC GetApprovedPR @UserId, + @SearchPRNo, @SearchItemName, @SearchDept, @SearchStatusName, + @PageNumber, @PageSize"; + foreach (var p in parameters) cmd.Parameters.Add(p); + cmd.CommandTimeout = 60; + + using var reader = await cmd.ExecuteReaderAsync(); + + // Result set 1 — distinct status list + while (await reader.ReadAsync()) + statusList.Add(reader.GetString(0)); + + // Result set 2 — total count + await reader.NextResultAsync(); + if (await reader.ReadAsync()) + totalCount = reader.GetInt32(0); + + // Result set 3 — paged rows + await reader.NextResultAsync(); + while (await reader.ReadAsync()) + { + items.Add(new ApprovedPR + { + PRId = reader["PRId"] as long? ?? 0, + PRNo = reader["PRNo"] as long? ?? 0, + PRDetailsId = reader["PRDetailsId"] as long? ?? 0, + ItemNo = reader["ItemNo"] as long? ?? 0, + ItemName = reader["ItemName"]?.ToString(), + Department = reader["Department"]?.ToString(), + StatusName = reader["StatusName"]?.ToString(), + DateNeeded = reader["DateNeeded"] as DateTime? ?? DateTime.UtcNow, + CreatedDate = reader["CreatedDate"] as DateTime? ?? DateTime.UtcNow, + AttestedDate = reader["AttestedDate"]?.ToString(), + ApprovedDate = reader["ApprovedDate"]?.ToString(), + Qty = Convert.ToDecimal(reader["Qty"]), + ApprovedBy = reader["ApprovedBy"]?.ToString(), + AttestedBy = reader["AttestedBy"]?.ToString(), + CreatedBy = reader["CreatedBy"]?.ToString(), + RemainingDays = reader["RemainingDays"] as int? ?? 0, + }); + } + + await conn.CloseAsync(); + + return new PagedResult + { + Data = items, + TotalCount = totalCount, + PageNumber = dto.PageNumber, + PageSize = dto.PageSize, + StatusList = statusList + }; + } + public async Task> GetAllPR(PRDto dto) + { + var parameters = new[] + { + new SqlParameter("@UserId", dto.UserId), + new SqlParameter("@SearchPRNo", dto.SearchPRNo ?? ""), + new SqlParameter("@SearchItemName", dto.SearchItemName ?? ""), + new SqlParameter("@SearchDept", dto.SearchDept ?? ""), + new SqlParameter("@PageNumber", dto.PageNumber), + new SqlParameter("@PageSize", dto.PageSize) + }; + + int totalCount = 0; + var items = new List(); + + var conn = _dbContext.Database.GetDbConnection(); + await conn.OpenAsync(); + + using var cmd = conn.CreateCommand(); + cmd.CommandText = @"EXEC GetAllPR @UserId, + @SearchPRNo, @SearchItemName, @SearchDept, + @PageNumber, @PageSize"; + foreach (var p in parameters) cmd.Parameters.Add(p); + + using var reader = await cmd.ExecuteReaderAsync(); + + if (await reader.ReadAsync()) + totalCount = reader.GetInt32(0); + + await reader.NextResultAsync(); + while (await reader.ReadAsync()) + { + items.Add(new Infrastructure.Entities.Purchasing.PRList + { + PRId = reader["PRId"] as long? ?? 0, + PRNo = reader["PRNo"] as long? ?? 0, + NewPRNo = reader["NewPRNo"]?.ToString(), + AggreItemName = reader["AggreItemName"]?.ToString(), + CreatedDate = reader["NewPRNo"] as DateTime? ?? DateTime.UtcNow, + DateNeeded = reader["DateNeeded"] as DateTime? ?? DateTime.UtcNow, + CreatedBy = reader["CreatedBy"]?.ToString(), + Department = reader["Department"]?.ToString(), + ApprovedBy = reader["ApprovedBy"]?.ToString(), + AttestedBy = reader["AttestedBy"]?.ToString(), + Remarks = reader["Remarks"]?.ToString(), + Status = reader["Status"] as short? ?? 0, + }); + } + + await conn.CloseAsync(); + + return new PagedResult + { + Data = items, + TotalCount = totalCount, + PageNumber = dto.PageNumber, + PageSize = dto.PageSize + }; + } + public async Task> GetPRArchived(PRDto dto) + { + var parameters = new[] + { + new SqlParameter("@UserId", dto.UserId), + new SqlParameter("@SearchPRNo", dto.SearchPRNo ?? ""), + new SqlParameter("@SearchItemName", dto.SearchItemName ?? ""), + new SqlParameter("@SearchDept", dto.SearchDept ?? ""), + new SqlParameter("@PageNumber", dto.PageNumber), + new SqlParameter("@PageSize", dto.PageSize) + }; + + int totalCount = 0; + var items = new List(); + + var conn = _dbContext.Database.GetDbConnection(); + await conn.OpenAsync(); + + using var cmd = conn.CreateCommand(); + cmd.CommandText = @"EXEC GetPRArchived @UserId, + @SearchPRNo, @SearchItemName, @SearchDept, + @PageNumber, @PageSize"; + foreach (var p in parameters) cmd.Parameters.Add(p); + + using var reader = await cmd.ExecuteReaderAsync(); + + if (await reader.ReadAsync()) + totalCount = reader.GetInt32(0); + + await reader.NextResultAsync(); + while (await reader.ReadAsync()) + { + items.Add(new Infrastructure.Entities.Purchasing.PRList + { + PRId = reader["PRId"] as long? ?? 0, + PRNo = reader["PRNo"] as long? ?? 0, + NewPRNo = reader["NewPRNo"]?.ToString(), + AggreItemName = reader["AggreItemName"]?.ToString(), + CreatedDate = reader["NewPRNo"] as DateTime? ?? DateTime.UtcNow, + DateNeeded = reader["DateNeeded"] as DateTime? ?? DateTime.UtcNow, + CreatedBy = reader["CreatedBy"]?.ToString(), + Department = reader["Department"]?.ToString(), + ApprovedBy = reader["ApprovedBy"]?.ToString(), + AttestedBy = reader["AttestedBy"]?.ToString(), + Remarks = reader["Remarks"]?.ToString(), + Status = reader["Status"] as short? ?? 0, + }); + } + + await conn.CloseAsync(); + + return new PagedResult + { + Data = items, + TotalCount = totalCount, + PageNumber = dto.PageNumber, + PageSize = dto.PageSize + }; } public async Task> GetApproverNameByPRNo(PRDto PRDto) { @@ -90,7 +413,6 @@ namespace CPRNIMS.Domain.Services.PR return new List(); } - public async Task> GetApproverName(PRDto PRDto) { var result = await _dbContext.Approved @@ -206,14 +528,6 @@ namespace CPRNIMS.Domain.Services.PR return new List(); } - public async Task> GetDetailedPRTracking(PRDto PRDto) - { - var allItems = await _dbContext.DetailedPRTrackings - .FromSqlRaw("EXEC GetDetailedPRTracking @UserId", - new SqlParameter("@UserId", PRDto.UserId)).ToListAsync(); - - return allItems ?? new List(); - } public async Task> GetSupplierAlternativeOffer(PRDto PRDto) { var rfq = await _dbContext.AlternativeOffers diff --git a/CPRNIMS.Domain/UIContracts/Items/IItem.cs b/CPRNIMS.Domain/UIContracts/Items/IItem.cs index aaf1960..e83e0cf 100644 --- a/CPRNIMS.Domain/UIContracts/Items/IItem.cs +++ b/CPRNIMS.Domain/UIContracts/Items/IItem.cs @@ -13,7 +13,8 @@ namespace CPRNIMS.Domain.UIContracts.Items { public interface IItem { - Task> GetItemList(User user, ItemVM viewModel); + Task> GetItemList( + User user, ItemVM viewModel); Task> GetItemDetail(User user, ItemVM viewModel); Task> GetItemCateg(User user, ItemVM viewModel); Task> GetItemLocalization(User userd, ItemVM viewModel); diff --git a/CPRNIMS.Domain/UIContracts/PR/IPRequest.cs b/CPRNIMS.Domain/UIContracts/PR/IPRequest.cs index 683dd1f..89e8be4 100644 --- a/CPRNIMS.Domain/UIContracts/PR/IPRequest.cs +++ b/CPRNIMS.Domain/UIContracts/PR/IPRequest.cs @@ -1,4 +1,5 @@ -using CPRNIMS.Infrastructure.Models.Account; +using CPRNIMS.Infrastructure.Dto.Items; +using CPRNIMS.Infrastructure.Models.Account; using CPRNIMS.Infrastructure.ViewModel.PR; using System; using System.Collections.Generic; @@ -11,9 +12,11 @@ namespace CPRNIMS.Domain.UIContracts.PR public interface IPRequest { #region Get - Task> GetAllPR(User user, PRVM viewModel); - Task?> GetApprovedPR(User user, PRVM viewModels); - Task?> GetRemovedPR(User user, PRVM viewModels); + Task> GetAllPR(User user, PRVM viewModel); + Task> GetDetailedPRTracking(User user, PRVM viewModel); + Task> GetPRArchived(User user, PRVM viewModel); + Task> GetApprovedPR(User user, PRVM viewModels); + Task> GetDeletedPR(User user, PRVM viewModels); Task?> GetApproverName(User user, PRVM viewModels); Task?> GetApproverNameByPRNo(User user, PRVM viewModels); Task> GetForReceiving(User user, PRVM viewModel); @@ -22,11 +25,9 @@ namespace CPRNIMS.Domain.UIContracts.PR Task> GetPRByRRId(User user, PRVM viewModel); Task> GetRRDetailByPO(User user, PRVM viewModel); Task> GetPRStatusById(User user, PRVM viewModel); - Task> GetPRArchived(User user, PRVM viewModel); Task> GetMyPR(User user, PRVM viewModel); Task> GetPRDetailByPRNo(User user, PRVM viewModel); Task?> GetPRListByPRNo(User user, PRVM viewModels); - Task?> GetDetailedPRTracking(User user, PRVM viewModel); Task?> GetSupplierAlternativeOffer(User user, PRVM viewModel); Task?> GetSupplierAlterOfferDetails(User user, PRVM viewModel); Task?> GetProjectCodes(User user, PRVM viewModels); diff --git a/CPRNIMS.Domain/UIServices/Items/Item.cs b/CPRNIMS.Domain/UIServices/Items/Item.cs index 2b004ef..6be9df1 100644 --- a/CPRNIMS.Domain/UIServices/Items/Item.cs +++ b/CPRNIMS.Domain/UIServices/Items/Item.cs @@ -1,5 +1,6 @@ using CPRNIMS.Domain.UIContracts.Common; using CPRNIMS.Domain.UIContracts.Items; +using CPRNIMS.Infrastructure.Dto.Items; using CPRNIMS.Infrastructure.Helper; using CPRNIMS.Infrastructure.Models.Account; using CPRNIMS.Infrastructure.Models.Common; @@ -31,7 +32,61 @@ namespace CPRNIMS.Domain.UIServices.Items _apiConfigurationService = apiConfigurationService; } #region SendRequest service - + public async Task> GetItemList( + Infrastructure.Models.Account.User user, ItemVM viewModel) + { + return await SendGetPageListApiRequest(user, viewModel, + _configuration["LLI:NonInvent:ItemMgmt:GetItemList"]); + } + public async Task> SendGetPageListApiRequest + (Infrastructure.Models.Account.User user,ItemVM viewModel,string apiEndpoint) + { + var token = await _tokenHelper.GetValidTokenAsync(); + + try + { + if (string.IsNullOrEmpty(token)) + { + // Handle token retrieval failure + return null; + } + + viewModel.UserId = user.UserId; + var jsonContent = JsonSerializer.Serialize(viewModel); + var content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); + + using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token)) + { + HttpResponseMessage response; + + response = await httpClient.PostAsync(apiEndpoint, content); + var jsonResponse = await response.Content.ReadAsStringAsync(); + + if (response.IsSuccessStatusCode) + { + var options = new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase + }; + viewModel.messCode = 1; + var myArtWork = JsonSerializer.Deserialize>(jsonResponse, options); + return myArtWork; + } + else + { + + var myArtWork = JsonSerializer.Deserialize>(jsonResponse); + viewModel.messCode = 0; + viewModel.message = "Bad request"; + return myArtWork; + } + } + } + catch (Exception ex) + { + throw; + } + } public async Task SendPostApiRequest(Infrastructure.Models.Account.User user, ItemVM viewModel, string apiEndpoint) { @@ -146,13 +201,13 @@ namespace CPRNIMS.Domain.UIServices.Items return await SendGetApiRequest(user, viewModel, _configuration["LLI:NonInvent:ItemMgmt:GetItemCart"]); } - public async Task> GetItemList(Infrastructure.Models.Account.User user, +/* public async Task> GetItemList(Infrastructure.Models.Account.User user, ItemVM viewModel) { return await SendGetApiRequest(user, viewModel, _configuration["LLI:NonInvent:ItemMgmt:GetItemList"]); } - +*/ public async Task> GetItemCateg(Infrastructure.Models.Account.User user, ItemVM viewModel) { return await SendGetApiRequest(user, viewModel, diff --git a/CPRNIMS.Domain/UIServices/PR/PRequest.cs b/CPRNIMS.Domain/UIServices/PR/PRequest.cs index 335ddf7..66dc4b6 100644 --- a/CPRNIMS.Domain/UIServices/PR/PRequest.cs +++ b/CPRNIMS.Domain/UIServices/PR/PRequest.cs @@ -1,5 +1,6 @@ using CPRNIMS.Domain.UIContracts.Common; using CPRNIMS.Domain.UIContracts.PR; +using CPRNIMS.Infrastructure.Dto.Items; using CPRNIMS.Infrastructure.Helper; using CPRNIMS.Infrastructure.Models.Account; using CPRNIMS.Infrastructure.Models.Common; @@ -129,11 +130,81 @@ namespace CPRNIMS.Domain.UIServices.PR { return await SendGetApiRequest(user, viewModel, _configuration["LLI:NonInvent:PRMgmt:GetApproverNameByPRNo"]); - } - public async Task> GetAllPR(User user, PRVM viewModel) + } + public async Task> GetAllPR( + User user, PRVM viewModel) { - return await SendGetApiRequest(user, viewModel, - _configuration["LLI:NonInvent:PRMgmt:GetAllPR"]); + return await SendGetPageListApiRequest(user, viewModel, + _configuration["LLI:NonInvent:PRMgmt:GetAllPR"]); + } + public async Task> GetPRArchived( + User user, PRVM viewModel) + { + return await SendGetPageListApiRequest(user, viewModel, + _configuration["LLI:NonInvent:PRMgmt:GetPRArchived"]); + } + public async Task> GetDeletedPR(User user, PRVM viewModel) + { + return await SendGetPageListApiRequest(user, viewModel, + _configuration["LLI:NonInvent:PRMgmt:GetDeletedPR"]); + } + public async Task> GetApprovedPR(User user, PRVM viewModel) + { + return await SendGetPageListApiRequest(user, viewModel, + _configuration["LLI:NonInvent:PRMgmt:GetApprovedPR"]); + } + public async Task> GetDetailedPRTracking(User user, PRVM viewModel) + { + return await SendGetPageListApiRequest(user, viewModel, + _configuration["LLI:NonInvent:PRMgmt:GetDetailedPRTracking"]); + } + public async Task> SendGetPageListApiRequest + (User user, PRVM viewModel, string apiEndpoint) + { + var token = await _tokenHelper.GetValidTokenAsync(); + + try + { + if (string.IsNullOrEmpty(token)) + { + return null; + } + + viewModel.UserId = user.UserId; + var jsonContent = JsonSerializer.Serialize(viewModel); + var content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); + + using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token)) + { + HttpResponseMessage response; + + response = await httpClient.PostAsync(apiEndpoint, content); + var jsonResponse = await response.Content.ReadAsStringAsync(); + + if (response.IsSuccessStatusCode) + { + var options = new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase + }; + viewModel.messCode = 1; + var myArtWork = JsonSerializer.Deserialize>(jsonResponse, options); + return myArtWork; + } + else + { + + var myArtWork = JsonSerializer.Deserialize>(jsonResponse); + viewModel.messCode = 0; + viewModel.message = "Bad request"; + return myArtWork; + } + } + } + catch (Exception ex) + { + throw; + } } public async Task> GetMyPR(User user, PRVM viewModel) { @@ -175,21 +246,11 @@ namespace CPRNIMS.Domain.UIServices.PR return await SendGetApiRequest(user, viewModel, _configuration["LLI:NonInvent:PRMgmt:GetDashBoard"]); } - public async Task> GetPRArchived(User user, PRVM viewModel) - { - return await SendGetApiRequest(user, viewModel, - _configuration["LLI:NonInvent:PRMgmt:GetPRArchived"]); - } public async Task?> GetPRListByPRNo(User user, PRVM viewModel) { return await SendGetApiRequest(user, viewModel, _configuration["LLI:NonInvent:PRMgmt:GetPRListByPRNo"]); } - public async Task?> GetDetailedPRTracking(User user, PRVM viewModel) - { - return await SendGetApiRequest(user, viewModel, - _configuration["LLI:NonInvent:PRMgmt:GetDetailedPRTracking"]); - } public async Task?> GetSupplierAlternativeOffer(User user, PRVM viewModel) { return await SendGetApiRequest(user, viewModel, @@ -200,17 +261,6 @@ namespace CPRNIMS.Domain.UIServices.PR return await SendGetApiRequest(user, viewModel, _configuration["LLI:NonInvent:PRMgmt:GetSupplierAlterOfferDetails"]); } - public async Task?> GetApprovedPR(User user, PRVM viewModel) - { - return await SendGetApiRequest(user, viewModel, - _configuration["LLI:NonInvent:PRMgmt:GetApprovedPR"]); - } - - public async Task?> GetRemovedPR(User user, PRVM viewModel) - { - return await SendGetApiRequest(user, viewModel, - _configuration["LLI:NonInvent:PRMgmt:GetRemovedPR"]); - } #endregion #region POST PUT public async Task PostPRApproveReject(User user, PRVM viewModel) diff --git a/CPRNIMS.Infrastructure/Database/NonInventoryDbContext.cs b/CPRNIMS.Infrastructure/Database/NonInventoryDbContext.cs index 4129d04..e9964bd 100644 --- a/CPRNIMS.Infrastructure/Database/NonInventoryDbContext.cs +++ b/CPRNIMS.Infrastructure/Database/NonInventoryDbContext.cs @@ -45,7 +45,7 @@ namespace CPRNIMS.Infrastructure.Database public virtual DbSet PRs { get; set; } public virtual DbSet Approved { get; set; } public virtual DbSet ApprovedPrs { get; set; } - public virtual DbSet RemovedPRs { get; set; } + public virtual DbSet DeletedPRs { get; set; } public virtual DbSet SMTPCredentials { get; set; } public virtual DbSet PRDetails { get; set; } public virtual DbSet PRItemLists { get; set; } @@ -115,7 +115,7 @@ namespace CPRNIMS.Infrastructure.Database public virtual DbSet PaymentTerms { get; set; } public virtual DbSet Incoterms { get; set; } public virtual DbSet CentralPONos { get; set; } - public virtual DbSet DetailedPRTrackings { get; set; } + public virtual DbSet DetailedPRTrackings { get; set; } public DbSet IncomingShipments { get; set; } public virtual DbSet IncomingShipmentDtos { get; set; } @@ -135,7 +135,7 @@ namespace CPRNIMS.Infrastructure.Database .Property(e => e.CanvassSupplierId) .ValueGeneratedNever(); - modelBuilder.Entity(b => + modelBuilder.Entity(b => { b.ToTable("DetailsedPRTracking"); b.HasNoKey(); diff --git a/CPRNIMS.Infrastructure/Dto/Items/ItemCodeDto.cs b/CPRNIMS.Infrastructure/Dto/Items/ItemCodeDto.cs index b50b47b..98034a0 100644 --- a/CPRNIMS.Infrastructure/Dto/Items/ItemCodeDto.cs +++ b/CPRNIMS.Infrastructure/Dto/Items/ItemCodeDto.cs @@ -23,5 +23,11 @@ namespace CPRNIMS.Infrastructure.Dto.Items public string? FileName { get; set; } public short Status { get; set; } public bool IsActive { get; set; } + public int PageNumber { get; set; } + public int PageSize { get; set; } + public string? SearchTerm { get; set; } + public string? SearchItemNo { get; set; } + public string? SearchItemName { get; set; } + public string? SearchCategory { get; set; } } } diff --git a/CPRNIMS.Infrastructure/Dto/Items/ItemDto.cs b/CPRNIMS.Infrastructure/Dto/Items/ItemDto.cs index c39c282..142b2f6 100644 --- a/CPRNIMS.Infrastructure/Dto/Items/ItemDto.cs +++ b/CPRNIMS.Infrastructure/Dto/Items/ItemDto.cs @@ -119,5 +119,7 @@ namespace CPRNIMS.Infrastructure.Dto.Items public long PRId { get; set; } public string? FileName { get; set; } public string? OrigFileName { get; set; } + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 10; } } diff --git a/CPRNIMS.Infrastructure/Dto/Items/PagedResult.cs b/CPRNIMS.Infrastructure/Dto/Items/PagedResult.cs new file mode 100644 index 0000000..85f6997 --- /dev/null +++ b/CPRNIMS.Infrastructure/Dto/Items/PagedResult.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CPRNIMS.Infrastructure.Dto.Items +{ + public class PagedResult + { + public List Data { get; set; }= new List(); + public int TotalCount { get; set; } + public int PageNumber { get; set; } + public int PageSize { get; set; } + public List StatusList { get; set; }= new List(); + public List CategoryList { get; set; } = new List(); + } +} diff --git a/CPRNIMS.Infrastructure/Dto/PR/PRDto.cs b/CPRNIMS.Infrastructure/Dto/PR/PRDto.cs index 4ae6844..04c0490 100644 --- a/CPRNIMS.Infrastructure/Dto/PR/PRDto.cs +++ b/CPRNIMS.Infrastructure/Dto/PR/PRDto.cs @@ -134,5 +134,12 @@ namespace CPRNIMS.Infrastructure.Dto.PR public long PRId { get; set; } public string? FileName { get; set; } public string? OrigFileName { get; set; } + public string SearchPRNo { get; set; } = ""; + public string SearchItemName { get; set; } = ""; + public string SearchDept { get; set; } = ""; + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 10; + public string SearchItemNo { get; set; } = string.Empty; + public string? SearchStatusName { get; set; } } } diff --git a/CPRNIMS.Infrastructure/Entities/Purchasing/ApprovedPR.cs b/CPRNIMS.Infrastructure/Entities/Purchasing/ApprovedPR.cs index e962105..aed52c1 100644 --- a/CPRNIMS.Infrastructure/Entities/Purchasing/ApprovedPR.cs +++ b/CPRNIMS.Infrastructure/Entities/Purchasing/ApprovedPR.cs @@ -15,16 +15,12 @@ namespace CPRNIMS.Infrastructure.Entities.Purchasing public long PRId { get; set; } public long ItemNo { get; set; } public string? ItemName { get; set; } - public string? ItemDescription { get; set; } public string? Department { get; set; } - public string? ItemCategoryName { get; set; } - public string? Remarks { get; set; } public string? StatusName { get; set; } public DateTime DateNeeded { get; set; } public DateTime CreatedDate { get; set; } public string? AttestedDate { get; set; } public string? ApprovedDate { get; set; } - public string? UOMName { get; set; } public decimal Qty { get; set; } public string? ApprovedBy { get; set; } public string? AttestedBy { get; set; } diff --git a/CPRNIMS.Infrastructure/Entities/Purchasing/RemovedPR.cs b/CPRNIMS.Infrastructure/Entities/Purchasing/DeletedPR.cs similarity index 80% rename from CPRNIMS.Infrastructure/Entities/Purchasing/RemovedPR.cs rename to CPRNIMS.Infrastructure/Entities/Purchasing/DeletedPR.cs index 78d1116..4a6b970 100644 --- a/CPRNIMS.Infrastructure/Entities/Purchasing/RemovedPR.cs +++ b/CPRNIMS.Infrastructure/Entities/Purchasing/DeletedPR.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace CPRNIMS.Infrastructure.Entities.Purchasing { - public class RemovedPR + public class DeletedPR { [Key] public long PRDetailsId { get; set; } @@ -15,16 +15,12 @@ namespace CPRNIMS.Infrastructure.Entities.Purchasing public long PRId { get; set; } public long ItemNo { get; set; } public string? ItemName { get; set; } - public string? ItemDescription { get; set; } public string? Department { get; set; } - public string? ItemCategoryName { get; set; } public string? Remarks { get; set; } - public string? StatusName { get; set; } public DateTime DateNeeded { get; set; } public DateTime CreatedDate { get; set; } public string? AttestedDate { get; set; } public string? ApprovedDate { get; set; } - public string? UOMName { get; set; } public decimal Qty { get; set; } public string? ApprovedBy { get; set; } public string? AttestedBy { get; set; } diff --git a/CPRNIMS.Infrastructure/Entities/Purchasing/DetailedPRTracking.cs b/CPRNIMS.Infrastructure/Entities/Purchasing/DetailedPRTracking.cs index e595931..3ebc3ca 100644 --- a/CPRNIMS.Infrastructure/Entities/Purchasing/DetailedPRTracking.cs +++ b/CPRNIMS.Infrastructure/Entities/Purchasing/DetailedPRTracking.cs @@ -8,12 +8,14 @@ using System.Threading.Tasks; namespace CPRNIMS.Infrastructure.Entities.Purchasing { [Keyless] - public class RRReport + public class DetailedPRTracking { public long PRDetailsId { get; set; } public string? PRBy { get; set; } public string? PRTypeName { get; set; } public DateTime PRDate { get; set; } + public long PRNo { get; set; } + public decimal Qty { get; set; } public string? AttestedBy { get; set; } public string? ApprovedBy { get; set; } public string? CanvassDate { get; set; } @@ -21,6 +23,7 @@ namespace CPRNIMS.Infrastructure.Entities.Purchasing public string? CanvassNo { get; set; } public string? PONo { get; set; } public string? POBy { get; set; } + public decimal POQty { get; set; } public string? PODate { get; set; } public string? RRDate { get; set; } public string? ReceivedDate { get; set; } @@ -38,11 +41,10 @@ namespace CPRNIMS.Infrastructure.Entities.Purchasing public string? NewPRNo { get; set; } public DateTime DateNeeded { get; set; } public long ItemNo { get; set; } - public decimal Qty { get; set; } public decimal QuantityReceived { get; set; } public string? UOMName { get; set; } public string? ItemAttachPath { get; set; } - public long PRNo { get; set; } + public string? Remarks { get; set; } } } diff --git a/CPRNIMS.Infrastructure/Entities/Purchasing/PRList.cs b/CPRNIMS.Infrastructure/Entities/Purchasing/PRList.cs index 33dd32d..9a62602 100644 --- a/CPRNIMS.Infrastructure/Entities/Purchasing/PRList.cs +++ b/CPRNIMS.Infrastructure/Entities/Purchasing/PRList.cs @@ -11,30 +11,17 @@ namespace CPRNIMS.Infrastructure.Entities.Purchasing public class PRList : CommonProperties { [Key] - public long PRDetailsId { get; set; } - public long ItemCodeId { get; set; } - public short ItemClassId { get; set; } + public long PRId { get; set; } + public long PRNo { get; set; } public string? Department { get; set; } - public string? ItemCategoryName { get; set; } - public string? UserId { get; set; } public string? AttestedBy { get; set; } public string? ApprovedBy { get; set; } - public decimal TotalAmount { get; set; } - public string? ItemDescription { get; set; } public short Status { get; set; } public string? StatusName { get; set; } - public bool IsActive { get; set; } public long ItemNo { get; set; } - public string? ItemLocalName { get; set; } - public decimal Qty { get; set; } public string? NewPRNo { get; set; } - public string? ItemClassName { get; set; } - public string? UOMName { get; set; } - public string? ItemColorName { get; set; } - public long PRNo { get; set; } - public long PRId { get; set; } - public string? Remarks { get; set; } public DateTime DateNeeded { get; set; } public string? AggreItemName { get; set; } + public string? Remarks { get; set; } } } diff --git a/CPRNIMS.Infrastructure/ViewModel/Items/ItemVM.cs b/CPRNIMS.Infrastructure/ViewModel/Items/ItemVM.cs index 0821c49..7a02ce3 100644 --- a/CPRNIMS.Infrastructure/ViewModel/Items/ItemVM.cs +++ b/CPRNIMS.Infrastructure/ViewModel/Items/ItemVM.cs @@ -61,5 +61,12 @@ namespace CPRNIMS.Infrastructure.ViewModel.Items public string? ProjectCode { get; set; } public string? OrigFileName { get; set; } public string? ProjectName { get; set; } + public string SearchTerm { get; set; } = ""; + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 10; + public int TotalCount { get; set; } + public string SearchItemNo { get; set; }=string.Empty; + public string SearchItemName { get; set; } = string.Empty; + public string SearchCategory { get; set; } = string.Empty; } } diff --git a/CPRNIMS.Infrastructure/ViewModel/PR/PRVM.cs b/CPRNIMS.Infrastructure/ViewModel/PR/PRVM.cs index e9d7614..6466888 100644 --- a/CPRNIMS.Infrastructure/ViewModel/PR/PRVM.cs +++ b/CPRNIMS.Infrastructure/ViewModel/PR/PRVM.cs @@ -11,6 +11,7 @@ namespace CPRNIMS.Infrastructure.ViewModel.PR public class PRVM : CommonProperties { public byte messCode; + public string message =string.Empty; public long ItemCodeId { get; set; } public long PRDetailsId { get; set; } public string? PRBy { get; set; } @@ -22,6 +23,7 @@ namespace CPRNIMS.Infrastructure.ViewModel.PR public string? CanvassBy { get; set; } public string? PONo { get; set; } public string? PODate { get; set; } + public decimal POQty { get; set; } public string? RRDate { get; set; } public string? ReceivedDate { get; set; } public string? ReceivedBy { get; set; } @@ -135,6 +137,14 @@ namespace CPRNIMS.Infrastructure.ViewModel.PR public string? AttestedDate { get; set; } public string? ApprovedDate { get; set; } public int RemainingDays { get; set; } + public string SearchPRNo { get; set; } = ""; + public string SearchItemName { get; set; } = ""; + public string SearchDept { get; set; } = ""; + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 10; + public string SearchTerm { get; set; } = string.Empty; + public string SearchStatusName { get; set; } = string.Empty; + public string SearchItemNo { get; set; } = string.Empty; public ItemReceivingList? ItemList { get; set; } public PRList? PRList { get; set; } public PRItemListRequest? PRItemListRequest { get; set; } diff --git a/CPRNIMS.WebApi/Controllers/Items/ItemMgmtController.cs b/CPRNIMS.WebApi/Controllers/Items/ItemMgmtController.cs index 7adeecf..1931499 100644 --- a/CPRNIMS.WebApi/Controllers/Items/ItemMgmtController.cs +++ b/CPRNIMS.WebApi/Controllers/Items/ItemMgmtController.cs @@ -108,7 +108,7 @@ namespace CPRNIMS.WebApi.Controllers.Items PRId = dto.PRId }; await _item.PostPutAttachment(attachment); - await SendNotificationEmail(dto); + //await SendNotificationEmail(dto); } return dto; diff --git a/CPRNIMS.WebApps/Controllers/Items/ItemMgmtController.cs b/CPRNIMS.WebApps/Controllers/Items/ItemMgmtController.cs index 77a7ae1..4c37a2b 100644 --- a/CPRNIMS.WebApps/Controllers/Items/ItemMgmtController.cs +++ b/CPRNIMS.WebApps/Controllers/Items/ItemMgmtController.cs @@ -327,11 +327,14 @@ namespace CPRNIMS.WebApps.Controllers.Items } } [HttpGet] - public async Task GetItemList(string searchTerm = "", int pageNumber = 1, int pageSize = 10) + public async Task GetItemList(string searchItemNo = "", string searchItemName = "", string searchCategory = "", + string searchStatusName = "", int pageNumber = 1, int pageSize = 10) { var viewModel = new ItemVM { - SearchTerm = searchTerm, + SearchItemName = searchItemName, + SearchItemNo = searchItemNo, + SearchCategory= searchCategory, PageNumber = pageNumber, PageSize = pageSize }; @@ -343,7 +346,8 @@ namespace CPRNIMS.WebApps.Controllers.Items draw = Request.Query["draw"].ToString(), recordsTotal = result.TotalCount, recordsFiltered = result.TotalCount, - data = result.Data + data = result.Data, + categoryList = result.CategoryList }); } public async Task GetItemCateg(ItemVM viewModels) @@ -574,34 +578,5 @@ namespace CPRNIMS.WebApps.Controllers.Items } #endregion - #region Commented - //private DriveService _driveService; - //public async Task Index() - //{ - // var filePath = "D:\\sourcecode\\test.txt"; - // var fileName = Path.GetFileName(filePath); - // var mimeType = "text/plain"; // Assuming the file is a text file - - // try - // { - // GoogleCredential credential = GoogleCredential.FromFile("path/to/service-account-key.json") - // .CreateScoped(DriveService.ScopeConstants.Drive); - - // // Create the Drive service using the service account credential - // _driveService = new DriveService(new BaseClientService.Initializer - // { - // HttpClientInitializer = credential, - // ApplicationName = "Your Application Name" - // }); - // } - // catch (Exception ex) - // { - // // Log the error or handle it appropriately - // // For example, you can throw an exception or set _driveService to null - // _driveService = null; - // } - // return View(); - //} - #endregion } } diff --git a/CPRNIMS.WebApps/Controllers/PR/PRMgmtController.cs b/CPRNIMS.WebApps/Controllers/PR/PRMgmtController.cs index 5a49802..34509e3 100644 --- a/CPRNIMS.WebApps/Controllers/PR/PRMgmtController.cs +++ b/CPRNIMS.WebApps/Controllers/PR/PRMgmtController.cs @@ -72,12 +72,13 @@ namespace CPRNIMS.WebApps.Controllers.PR }); } public async Task GetDetailedPRTracking( - string searchPRNo = "", string searchItemName = "", string searchDept = "", string searchStatusName = "", + string searchPRNo = "",string srchItemNo ="", string searchItemName = "", string searchDept = "", string searchStatusName = "", int pageNumber = 1, int pageSize = 10) { var dto = new PRVM { SearchPRNo = searchPRNo, + SearchItemNo = srchItemNo, SearchItemName = searchItemName, SearchDept = searchDept, SearchStatusName = searchStatusName, diff --git a/CPRNIMS.WebApps/Views/ItemMgmt/Index.cshtml b/CPRNIMS.WebApps/Views/ItemMgmt/Index.cshtml index ee79eb4..751a974 100644 --- a/CPRNIMS.WebApps/Views/ItemMgmt/Index.cshtml +++ b/CPRNIMS.WebApps/Views/ItemMgmt/Index.cshtml @@ -10,28 +10,54 @@ Add new
- -
-
- - - - - - - - - - - - +
+ +
+
+ + + + + + + + +
+
+ + +
+
+ + + + + + + + +
+
+ +
+
+ + + + + + +
-
Start typing to search items…
@@ -258,7 +284,7 @@ - + @await Html.PartialAsync("PagesView/Item/_Scripts") diff --git a/CPRNIMS.WebApps/Views/ItemMgmt/ItemCart.cshtml b/CPRNIMS.WebApps/Views/ItemMgmt/ItemCart.cshtml index bb47ba5..acf4a84 100644 --- a/CPRNIMS.WebApps/Views/ItemMgmt/ItemCart.cshtml +++ b/CPRNIMS.WebApps/Views/ItemMgmt/ItemCart.cshtml @@ -139,5 +139,5 @@ @await Html.PartialAsync("PagesView/Item/_Scripts") - + \ No newline at end of file diff --git a/CPRNIMS.WebApps/Views/PRMgmt/Index.cshtml b/CPRNIMS.WebApps/Views/PRMgmt/Index.cshtml index 8439ae5..dbe2244 100644 --- a/CPRNIMS.WebApps/Views/PRMgmt/Index.cshtml +++ b/CPRNIMS.WebApps/Views/PRMgmt/Index.cshtml @@ -33,28 +33,54 @@ + @@ -115,6 +132,6 @@ - + @await Html.PartialAsync("PagesView/PR/_PRScripts") \ No newline at end of file diff --git a/CPRNIMS.WebApps/Views/Shared/PagesView/Item/_Scripts.cshtml b/CPRNIMS.WebApps/Views/Shared/PagesView/Item/_Scripts.cshtml index a146756..7e8ffe0 100644 --- a/CPRNIMS.WebApps/Views/Shared/PagesView/Item/_Scripts.cshtml +++ b/CPRNIMS.WebApps/Views/Shared/PagesView/Item/_Scripts.cshtml @@ -7,10 +7,12 @@ - + + + \ No newline at end of file diff --git a/CPRNIMS.WebApps/Views/Shared/PagesView/PR/_PRScripts.cshtml b/CPRNIMS.WebApps/Views/Shared/PagesView/PR/_PRScripts.cshtml index a8ec9f0..9fd175e 100644 --- a/CPRNIMS.WebApps/Views/Shared/PagesView/PR/_PRScripts.cshtml +++ b/CPRNIMS.WebApps/Views/Shared/PagesView/PR/_PRScripts.cshtml @@ -4,8 +4,8 @@ - - + + @@ -16,7 +16,7 @@ - + diff --git a/CPRNIMS.WebApps/appsettings.json b/CPRNIMS.WebApps/appsettings.json index 6e84068..6f57e9e 100644 --- a/CPRNIMS.WebApps/appsettings.json +++ b/CPRNIMS.WebApps/appsettings.json @@ -62,9 +62,10 @@ "PostPutAttachment": "api/PRMgmt/PostPutAttachment/", "ApprovedSelectedPRItem": "api/PRMgmt/ApprovedSelectedPRItem/", "PostPutProjectCode": "api/PRMgmt/PostPutProjectCode/", + "PostItemInPR": "api/PRMgmt/PostItemInPR/", "GetAllPR": "api/PRMgmt/GetAllPR/", "GetApprovedPR": "api/PRMgmt/GetApprovedPR/", - "GetRemovedPR": "api/PRMgmt/GetRemovedPR/", + "GetDeletedPR": "api/PRMgmt/GetDeletedPR/", "GetPRArchived": "api/PRMgmt/GetPRArchived/", "GetMyPR": "api/PRMgmt/GetMyPR/", "GetApproverName": "api/PRMgmt/GetApproverName/", diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemCartV3.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemCartV4.js similarity index 88% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemCartV3.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemCartV4.js index ff799e7..349bccb 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemCartV3.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemCartV4.js @@ -64,6 +64,7 @@ $(document).ready(function () { }, 'selected-row', '.select-all-item-checkbox'); tableElement = $(tableName); + tableDestroy(tableElement); UserRights = document.getElementById("roleRights").value; @@ -99,7 +100,6 @@ $(document).ready(function () { var data = api.ajax.json(); if (!data || !data.data || data.data === "No Data") { - // Display the "No record available" message $('.dataTables_empty').html("No record available"); } updateSubmitButtonVisibility(); @@ -129,26 +129,24 @@ $(document).ready(function () { "columnDefs": [ { - "targets": [5], // Index of the 'qty' column (0-based) + "targets": [5], "render": function (data, type, row) { - // Render the 'qty' column as an input field return ''; } } ], rowCallback: function (row, data) { - var cartItemCount = data.cartItemCount; // Retrieve the cart item count from the data object - var itemCount = parseInt(cartItemCount, 10); // Parse the text content as an integer + var cartItemCount = data.cartItemCount; + var itemCount = parseInt(cartItemCount, 10); var prTypeIdCell = $('td:eq(4)', row); var PRTypeId = prTypeIdCell.text(); var PRTypeIdNumer = parseInt(PRTypeId, 10); - // console.log('ItemCartIds', ItemCartId); - // Check if the parsed integer is a valid number + if (!isNaN(itemCount)) { - $('#cartCount').text(itemCount); // Update the cart count in the navbar + $('#cartCount').text(itemCount); } else { - $('#cartCount').text('0'); // If the parsed integer is NaN, set the cart count to 0 + $('#cartCount').text('0'); } if (!isNaN(PRTypeIdNumer)) { if (PRTypeIdNumer === 1) { @@ -158,23 +156,16 @@ $(document).ready(function () { } } }, - //responsive: true, + order: [[0, 'desc']], language: { emptyTable: "No record available" }, - error: function (xhr, error, thrown) { - console.log('DataTables error:', error); - console.log('Status:', Status); - console.log('Details:', xhr.responseText); - window.location.href = '/Home/Logout'; - } + error: errorHandler }); - // Function to update the visibility of the submit button - function updateSubmitButtonVisibility() { - var isEmpty = itemTable.data().length === 0; // Check if the table is empty - // Toggle the visibility of the submit button based on whether the table is empty or not + function updateSubmitButtonVisibility() { + var isEmpty = itemTable.data().length === 0; submitButton.toggle(!isEmpty); } }) diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemColumns.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemColumns.js new file mode 100644 index 0000000..0dbb161 --- /dev/null +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemColumns.js @@ -0,0 +1,12 @@ +var colOnItemList = [ + { data: 'itemNo' }, + { data: 'itemName' }, + { data: 'itemDescription' }, + { data: 'itemCategoryName' }, + { + data: null, + render: function (data, type, row) { + return renderItembtns(data, row); + } + } +] \ No newline at end of file diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemManagementV9.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemManagement.js similarity index 57% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemManagementV9.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemManagement.js index 6011c20..d052054 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemManagementV9.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/ItemManagement.js @@ -41,47 +41,59 @@ function isFullFilled() { $(document).ready(function () { loader = $('#overlay, #loader'); + const reportTitle = `Item List - as of ${getFormattedDateTime()}`; let cartItemCount = $('#cartItemCount').val(); $('#cartCount').text(cartItemCount); - + const endpoint = '/ItemMgmt/GetItemList'; itemTable = $('#ItemTable').DataTable({ serverSide: true, processing: true, - searching: false, // disable built-in search box (we drive it manually) - + searching: false, + ordering: false, ajax: { - url: '/ItemMgmt/GetItemList', + url: endpoint, type: 'GET', data: function (d) { - var searchVal = $('#customSearch').length ? $('#customSearch').val() : ''; - return { draw: d.draw, - searchTerm: (searchVal || '').trim(), + searchItemNo: ($('#srchItemNo').val() || '').trim(), + searchItemName: ($('#srchItem').val() || '').trim(), + searchCategory: ($('#srchCategory').val() || '').trim(), pageNumber: Math.floor(d.start / d.length) + 1, pageSize: d.length }; }, dataSrc: function (json) { - return json.data; // ← extract data array here + const $sel = $('#srchCategory'); + if ($sel.find('option').length <= 1 && json.categoryList?.length) { + json.categoryList.forEach(function (s) { + $sel.append(``); + }); + } + return json.data; }, beforeSend: function () { loader.show(); }, complete: function () { loader.hide(); }, }, - - columns: [ - { data: 'itemNo' }, - { data: 'itemName' }, - { data: 'itemDescription' }, - { data: 'itemCategoryName' }, + dom: 'lBfrtip', + buttons: [ { - data: null, - render: function (data, type, row) { - return renderItembtns(data, row); - } + text: ' CSV', + className: 'btn btn-sm btn-secondary', + action: function () { exportAllData('csv', endpoint, loader, reportTitle, colOnItemList); } + }, + { + text: ' Excel', + className: 'btn btn-sm btn-success', + action: function () { exportAllData('excel', endpoint, loader, reportTitle, colOnItemList); } + }, + { + text: ' PDF', + className: 'btn btn-sm btn-danger', + action: function () { exportAllData('pdf', endpoint, loader, reportTitle, colOnItemList); } } ], - + columns: colOnItemList, order: [[0, 'desc']], responsive: true, @@ -90,7 +102,6 @@ $(document).ready(function () { } }); - // Debounce helper function debounce(fn, delay) { let t; return function (...args) { @@ -99,21 +110,33 @@ $(document).ready(function () { }; } - // Custom search box - $('#customSearch').on('keyup', debounce(function () { - if ($(this).val().trim().length === 0) { - itemTable.clear().draw(); // show nothing until user types - return; - } - itemTable.ajax.reload(); // triggers new server call with searchTerm - }, 400)); + $('#srchItem, #srchItemNo') + .on('keyup', debounce(() => itemTable.ajax.reload(null, false), 400)); + + $('#srchCategory').on('change', function () { + itemTable.ajax.reload(null, false); + }); + $('.aprv-search-clear').on('click', function () { + $($(this).data('target')).val('').trigger('change'); + }); + }); +function getFormattedDateTime() { + const now = new Date(); + const yyyy = now.getFullYear(); + const mm = String(now.getMonth() + 1).padStart(2, '0'); + const dd = String(now.getDate()).padStart(2, '0'); + const hh = String(now.getHours()).padStart(2, '0'); + const min = String(now.getMinutes()).padStart(2, '0'); + const ss = String(now.getSeconds()).padStart(2, '0'); + return `${yyyy}-${mm}-${dd}_${hh}${min}${ss}`; +} document.addEventListener('DOMContentLoaded', function () { const triggers = Array.from(document.querySelectorAll('[data-bs-toggle="tooltip"]')); triggers.forEach(el => { new bootstrap.Tooltip(el, { - container: 'body', // append tooltip to body - boundary: 'window', // prevent clipping + container: 'body', + boundary: 'window', }); }); }); diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/PostPutItemV4.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/PostPutItemV5.js similarity index 97% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/Items/PostPutItemV4.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/Items/PostPutItemV5.js index 149b529..e06c919 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/PostPutItemV4.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Items/PostPutItemV5.js @@ -12,10 +12,19 @@ } const requestData = selectedItems.map(item => { + const row = itemTable.rows().nodes().toArray().find(row => { + const rowData = itemTable.row(row).data(); + return rowData.itemNo === item.itemNo; + }); + + const updatedQty = row + ? parseFloat($(row).find('.editable-qty').val()) || item.qty + : item.qty; + return { ItemCartId: item.itemCartId, ItemNo: item.itemNo, - Qty: item.qty + Qty: updatedQty }; }); @@ -45,31 +54,28 @@ cancelText: 'No' }).then((confirmed) => { if (confirmed) { - // Create FormData to handle file upload + var formData = new FormData(); - // Append file if exists var fileInput = document.getElementById('fileAttachment'); if (fileInput.files.length > 0) { formData.append('file', fileInput.files[0]); } - // Append other data formData.append('DateNeeded', DateNeeded); formData.append('RequestTypeId', RequestTypeId); formData.append('ChargeTo', ChargeTo || ''); formData.append('Remarks', Remarks || ''); formData.append('ProjectCodeId', ProjectCodeId || 0); - // Append array data - serialize as JSON formData.append('ItemCartIds', JSON.stringify(requestData)); $.ajax({ url: '/ItemMgmt/PostPurchRequest', type: 'POST', data: formData, - processData: false, // Important: Don't process the data - contentType: false, // Important: Don't set content type + processData: false, + contentType: false, success: function (response) { if (response.success) { itemTable.ajax.reload(); @@ -78,7 +84,6 @@ var totalSelectedLabel = $('#totalSelected'); totalSelectedLabel.text(''); - // Clear form after successful submission clearFormData(); } else { itemTable.ajax.reload(); @@ -96,8 +101,6 @@ } }); } - - function putItemDetails() { loader = $('#overlay, #loader'); const itemPictureImageInput = document.getElementById("itemPictureImageInput"); diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/DetailedPRTrackingV9.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/DetailedPRTracking.js similarity index 94% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/PR/DetailedPRTrackingV9.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/PR/DetailedPRTracking.js index e1223b9..c3cb1fc 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/DetailedPRTrackingV9.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/DetailedPRTracking.js @@ -14,6 +14,7 @@ return { draw: d.draw, searchPRNo: ($('#srchPRNo').val() || '').trim(), + srchItemNo: ($('#srchItemNo').val() || '').trim(), searchItemName: ($('#srchItem').val() || '').trim(), searchDept: ($('#srchDept').val() || '').trim(), searchStatusName: ($('#srchStatus').val() || '').trim(), @@ -57,6 +58,8 @@ } ], columns: colOnPRtracking, + pageLength: 5, + lengthMenu: [[5, 10, 25, 50, 100], [5, 10, 25, 50, 100]], rowCallback: rowStatusColorCallback, language: { emptyTable: "No approved records available" } }); @@ -69,7 +72,7 @@ }; } - $('#srchPRNo, #srchItem, #srchDept') + $('#srchPRNo, #srchItemNo, #srchItem, #srchDept') .on('keyup', debounce(() => prTable.ajax.reload(), 400)); $('#srchStatus').on('change', function () { diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRColumnV9.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRColumn.js similarity index 97% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRColumnV9.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRColumn.js index b513a57..cf89e14 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRColumnV9.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRColumn.js @@ -50,6 +50,12 @@ var colOnPRtracking = [ { data: 'poNo', title: 'PONo' }, { data: 'poBy', title: 'POBy' }, { data: 'poDate', title: 'PODate' }, + { + data: 'poQty', title: 'POQty', + render: function (data, type, row, meta) { + return numberWithCommas(data); + } + }, { data: 'rrNo', title: 'RRNo' }, { data: 'receivedBy', title: 'ReceivedBy' }, { data: 'rrDate', title: 'RRDate' }, diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRViewV9.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRView.js similarity index 97% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRViewV9.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRView.js index 8826e83..646a613 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRViewV9.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/PRView.js @@ -23,19 +23,24 @@ url: '/ItemMgmt/GetItemList', type: 'GET', data: function (d) { - var searchVal = $('#modalSearchInput').length - ? $('#modalSearchInput').val() - : ''; return { draw: d.draw, - searchTerm: (searchVal || '').trim(), + searchItemNo: ($('#srchItemNo').val() || '').trim(), + searchItemName: ($('#srchIteName').val() || '').trim(), + searchCategory: ($('#srchCategory').val() || '').trim(), pageNumber: Math.floor(d.start / d.length) + 1, pageSize: d.length }; }, dataSrc: function (json) { + const $sel = $('#srchCategory'); + if ($sel.find('option').length <= 1 && json.categoryList?.length) { + json.categoryList.forEach(function (s) { + $sel.append(``); + }); + } return json.data; - } + }, }, responsive: true, language: { @@ -87,7 +92,6 @@ error: errorHandler }); - // Debounce helper (local scope) function debounce(fn, delay) { let t; return function (...args) { @@ -96,23 +100,14 @@ }; } - // Search input handler - $('#modalSearchInput').off('keyup').on('keyup', debounce(function () { - const val = $(this).val().trim(); - $('#modalSearchHint').text(val.length ? `Searching for "${val}"…` : 'Start typing to search items…'); - itemListTable.ajax.reload(); - }, 400)); + $('#srchIteName, #srchItemNo') + .on('keyup', debounce(() => itemListTable.ajax.reload(null, false), 400)); - // Show/hide clear button - $('#modalSearchInput').off('input').on('input', function () { - $('#modalSearchClear').css('display', $(this).val().length ? 'flex' : 'none'); + $('#srchCategory').on('change', function () { + itemListTable.ajax.reload(null, false); }); - - // Clear button handler - $('#modalSearchClear').off('click').on('click', function () { - $('#modalSearchInput').val('').trigger('input'); - $('#modalSearchHint').text('Start typing to search items…'); - itemListTable.ajax.reload(); + $('.aprv-search-clear').on('click', function () { + $($(this).data('target')).val('').trigger('change'); }); // Editable qty handler diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Utilities/ExportCSVExcel.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Utilities/ExportCSVExcelV2.js similarity index 97% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/Utilities/ExportCSVExcel.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/Utilities/ExportCSVExcelV2.js index b0387c6..f372c2a 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/Utilities/ExportCSVExcel.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Utilities/ExportCSVExcelV2.js @@ -1,6 +1,7 @@ function exportAllData(format, api, loader, reportTitle, column) { const params = new URLSearchParams({ searchPRNo: ($('#srchPRNo').val() || '').trim(), + searchItemNo: ($('#srchItemNo').val() || '').trim(), searchItemName: ($('#srchItem').val() || '').trim(), searchDept: ($('#srchDept').val() || '').trim(), searchStatusName: ($('#srchStatus').val() || '').trim(),
PONo POBy PODatePOQty RRNo RRBy RRDate