diff --git a/CPRNIMS.Domain/Services/Finance/RR.cs b/CPRNIMS.Domain/Services/Finance/RR.cs index b93b555..88e9e7b 100644 --- a/CPRNIMS.Domain/Services/Finance/RR.cs +++ b/CPRNIMS.Domain/Services/Finance/RR.cs @@ -1,7 +1,6 @@ using CPRNIMS.Domain.Contracts.Finance; using CPRNIMS.Infrastructure.Database; using CPRNIMS.Infrastructure.Dto.Finance; -using CPRNIMS.Infrastructure.Dto.Items; using CPRNIMS.Infrastructure.Entities.Finance; using CPRNIMS.Infrastructure.Entities.Purchasing; using Microsoft.Data.SqlClient; @@ -23,19 +22,11 @@ namespace CPRNIMS.Domain.Services.Finance } public async Task> GetAllClosedPO(RRDetailsDto itemDto) { - try - { - var allItems = await _dbContext.ForPayments + var allItems = await _dbContext.ForPayments .FromSqlRaw($"EXEC GetAllClosedPO @UserId = '{itemDto.UserId}'") .ToListAsync(); - return allItems ?? new List(); - } - catch (SqlException ex) - { - ex.ToString(); - throw; - } + return allItems ?? new List(); } public async Task> GetRRDetailByPO(RRDetailsDto itemDto) { @@ -51,21 +42,13 @@ namespace CPRNIMS.Domain.Services.Finance public async Task PostPutPayment(RRDetailsDto itemDto) { - try - { - await _dbContext.Database - .ExecuteSqlRawAsync("EXEC PostPutPayment @UserId, @PONo, @POTypeId, @PRDetailsId", - new SqlParameter("@UserId", itemDto.UserId), - new SqlParameter("@PONo", itemDto.PONo), - new SqlParameter("@POTypeId", itemDto.POTypeId), - new SqlParameter("@PRDetailsId", itemDto.PRDetailsId)); - return new RRDetail(); - } - catch (SqlException ex) - { - ex.ToString(); - throw; - } + await _dbContext.Database + .ExecuteSqlRawAsync("EXEC PostPutPayment @UserId, @PONo, @POTypeId, @PRDetailsId", + new SqlParameter("@UserId", itemDto.UserId), + new SqlParameter("@PONo", itemDto.PONo), + new SqlParameter("@POTypeId", itemDto.POTypeId), + new SqlParameter("@PRDetailsId", itemDto.PRDetailsId)); + return new RRDetail(); } } } diff --git a/CPRNIMS.WebApi/Controllers/Account/AccountController.cs b/CPRNIMS.WebApi/Controllers/Account/AccountController.cs index abb5808..338a743 100644 --- a/CPRNIMS.WebApi/Controllers/Account/AccountController.cs +++ b/CPRNIMS.WebApi/Controllers/Account/AccountController.cs @@ -385,34 +385,15 @@ namespace CPRNIMS.WebApi.Controllers.Account [HttpPost("GetLandingPageByUserId")] public async Task GetLandingPageByUserId(ControllerAccessVM model) { - try - { - var controllerAccesse = await _controllerAccess.GetControllerAccessByUserId(model.UserId); - return Ok(controllerAccesse); - - } - catch (Exception ex) - { - var message = ex.InnerException?.ToString() ?? ex.Message.ToString(); - await PostErrorMessage(message, "WebApi"); - throw; - } + return await ExecuteWithErrorHandling( + () => _controllerAccess.GetControllerAccessByUserId(model.UserId), + nameof(GetLandingPageByUserId), false); } [HttpGet("GetAllRoles")] public async Task GetAllRoles() { - try - { - var roles = await _roleManager.Roles.ToListAsync(); - return Ok(roles); - - } - catch (Exception ex) - { - var message = ex.InnerException?.ToString() ?? ex.Message.ToString(); - await PostErrorMessage(message, "WebApi"); - throw; - } + var roles = await _roleManager.Roles.ToListAsync(); + return Ok(roles); } [HttpGet("GetRoles")] public async Task GetRoles() @@ -434,7 +415,7 @@ namespace CPRNIMS.WebApi.Controllers.Account } else { - return NotFound(); // or any other appropriate status code + return NotFound(); } } catch (Exception ex) diff --git a/CPRNIMS.WebApps/Views/Receiving/Index.cshtml b/CPRNIMS.WebApps/Views/Receiving/Index.cshtml index e165ed8..92983b2 100644 --- a/CPRNIMS.WebApps/Views/Receiving/Index.cshtml +++ b/CPRNIMS.WebApps/Views/Receiving/Index.cshtml @@ -49,7 +49,7 @@ @await Html.PartialAsync("PagesView/Receiving/_Receiving") - - @await Html.PartialAsync("PagesView/Receiving/_ReceivingScripts") - \ No newline at end of file + + +@await Html.PartialAsync("PagesView/Receiving/_ReceivingScripts") \ No newline at end of file diff --git a/CPRNIMS.WebApps/Views/Shared/PagesView/Receiving/_ReceivingScripts.cshtml b/CPRNIMS.WebApps/Views/Shared/PagesView/Receiving/_ReceivingScripts.cshtml index c618c9e..4391c80 100644 --- a/CPRNIMS.WebApps/Views/Shared/PagesView/Receiving/_ReceivingScripts.cshtml +++ b/CPRNIMS.WebApps/Views/Shared/PagesView/Receiving/_ReceivingScripts.cshtml @@ -2,11 +2,11 @@
- - + + - + \ No newline at end of file diff --git a/CPRNIMS.WebApps/Views/Shared/PartialView/_Sidebar.cshtml b/CPRNIMS.WebApps/Views/Shared/PartialView/_Sidebar.cshtml index 32f9a48..e55d9b0 100644 --- a/CPRNIMS.WebApps/Views/Shared/PartialView/_Sidebar.cshtml +++ b/CPRNIMS.WebApps/Views/Shared/PartialView/_Sidebar.cshtml @@ -16,8 +16,7 @@ var myControllerAccess = await _account.GetLandingPageByUserId(userCred); var groupedElements = myControllerAccess.GroupBy(e => e.ElementMenuName).ToList(); - - // Pass the data to the view + ViewBag.TempDataElements = groupedElements; } diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Finance/RRColumnV2.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Finance/RRColumnV2.js index 510e87a..f227711 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/Finance/RRColumnV2.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Finance/RRColumnV2.js @@ -63,8 +63,7 @@ var colDefForReceivingSKU = [ UserRights == 'LITCRequestor' && UserRights == 'LPCRequestor' && UserRights == 'Approver1' && UserRights == 'Approver2') { return ''; - } else { - console.log('ELSE PASOK BA?'); + } else { // Non-admin users get a readonly input return ''; } diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/PO/POPutPostV2.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/PO/POPutPostV2.js index 63ed475..cdc5f16 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/PO/POPutPostV2.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/PO/POPutPostV2.js @@ -79,7 +79,7 @@ function putPOItemDetail() { const PortOfDischarge = portOfDischarge.value; var poTypeId = $('#potype-cancel').val(); - console.log('PodId', PodId); + if (!UOMId || !Specification || !Qty || !UnitPrice || !PaymentTermsId || PaymentTermsId == 0 || !ItemDescription) { showToast('warning', 'Please fill the required fields !', 'Updating failed!', 4000); if (!UOMId) { diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingPostPut.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingPostPutV2.js similarity index 87% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingPostPut.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingPostPutV2.js index 21ce713..b4d4cc0 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingPostPut.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingPostPutV2.js @@ -83,26 +83,32 @@ return; } - const confirmation = confirm('Are you sure you want to proceed?'); + showConfirmation({ + title: 'Receiving', + message: 'Are you sure you want to receive this item? This action cannot be undone.', + type: 'warning', + confirmText: 'Yes', + cancelText: 'No' + }).then((confirmed) => { + if (confirmed) { + $.ajax($.extend({ + url: '/Receiving/PostPutReceiving', + type: 'POST', + data: { ItemList, POTypeId, EmailAddress, PONo, DocTypeId, Remarks, DRNo, ReceivedDate, RRNo, IsCompleted }, + success: function (response) { + if (response.success) { + $('#viewRRDetailByPO').modal('hide'); + receivingTable.ajax.reload(); - if (confirmation) { - $.ajax($.extend({ - url: '/Receiving/PostPutReceiving', - type: 'POST', - data: { ItemList, POTypeId, EmailAddress, PONo, DocTypeId, Remarks, DRNo, ReceivedDate, RRNo, IsCompleted }, - success: function (response) { - if (response.success) { - $('#viewRRDetailByPO').modal('hide'); - receivingTable.ajax.reload(); - - alert('Item Received Successfully!'); - } else { - alert('Failed: ' + response.response); - } - }, - error: errorHandler - }, beforeComplete(loader))); - } + showToast('success', 'Item Received Successfully!', 'Receiving', 4000); + } else { + showToast('error', response.response, 'Updating failed!', 4000); + } + }, + error: errorHandler + }, beforeComplete(loader))); + } + }); } function putPOClose() { loader = $('#overlay, #loader').css('z-index', 1070); diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV3.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV4.js similarity index 99% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV3.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV4.js index 62008db..4501f1e 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV3.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV4.js @@ -22,7 +22,7 @@ amountUSD.style.display = 'none'; amountUSDLabel.style.display = 'none'; } - if (UserRights !== 'LLIFINANCE' && UserRights !== 'CnvssAppver' && UserRights !== 'POApprover') { //dont touch && + if (UserRights !== 'CnvssAppver' && UserRights !== 'POApprover') { //dont touch && btnSubmit.style.display = 'none'; amountUSDLabel.style.display = 'none'; vatRateLabel.style.display = 'none'; @@ -36,7 +36,7 @@ //let btnIncomplete = document.getElementById('btnIncomplete'); let btnClosePO = document.getElementById('btnClosePO'); btnPayment.style.display = 'none'; - if (UserRights == 'POApprover' || UserRights == 'LLIFINANCE' || UserRights == 'CnvssAppver') { + if (UserRights == 'POApprover' || UserRights == 'CnvssAppver') { btnSubmit.style.display = 'none'; btnReject.style.display = 'none'; dynamicColumn = colRRFinance;