From a1db9175a3e409a2aaca2dc2d51204b198850ab9 Mon Sep 17 00:00:00 2001 From: ameerulrasyid Date: Mon, 10 Mar 2025 15:59:40 +0800 Subject: [PATCH 01/52] fix item movement qr master --- .../Views/InventoryMaster/QrMaster.cshtml | 58 ++++++++++++++----- Controllers/API/Inventory/InvMainAPI.cs | 4 +- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml b/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml index 1b0258f..9ce62fd 100644 --- a/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml +++ b/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml @@ -144,8 +144,8 @@
- -
+ +

Item is on Delivery

@@ -169,6 +169,23 @@
+
+

Receive Item

+
+
+
+
+ +
+ +
+
+
+
+
+

Receive Repair / Calibration

@@ -226,7 +243,7 @@ @*
*@ @*
*@ -
+

Add Item Movement

@@ -240,7 +257,7 @@
-
+

Add Item Movement

@@ -730,8 +747,9 @@ }) .then(() => { console.log("📷 Applied Constraintsss:", track.getSettings()); - }).catch(err => - // console.error("❌ Failed to apply constraints:", err) + }) + .catch(err => + console.error("❌ Failed to apply constraints:", err) ); } else { @@ -812,9 +830,9 @@ ...(this.selectedAction === 'user' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), ...(this.selectedAction === 'station' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastStation: this.selectedStation, lastUser: this.selectedStationPIC, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), - ...(this.selectedAction === 'store' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), - ...(this.selectedAction === 'supplier' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther, ConsignmentNote: this.document, lastUser: this.currentUser.id, MovementComplete: false, } : {}), - ...(this.selectedAction === 'faulty' ? { toStore: this.currentUser.store, toUser: this.currentUser.id,toOther: 'Faulty', Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, } : {}), + ...(this.selectedAction === 'store' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastStore: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), + ...(this.selectedAction === 'supplier' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther, ConsignmentNote: this.document, lastUser: this.currentUser.id, lastStore: this.currentUser.store, MovementComplete: false, } : {}), + ...(this.selectedAction === 'faulty' ? { toStore: this.currentUser.store, toUser: this.currentUser.id,toOther: 'Faulty', SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, } : {}), ItemId: this.thisItem.itemID, Action: 'Stock Out', @@ -863,19 +881,23 @@ this.serialNumber = ""; } - if(this.thisItem.toOther === "On Delivery"){ + if(this.thisItem.toOther === "On Delivery" && this.thisItem.toUser == this.currentUser.id){ if(!window.confirm("Are you sure you want to cancel item delivery?")){ return; } } const now = new Date(); + console.log('currentuser'+this.currentUser.id); + console.log('lastuser'+this.thisItem.lastuser); + const formData = { Id: this.thisItem.movementId, ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), - Remark: this.thisItem.toOther === "On Delivery" ? this.thisItem.remark + ". Inventory Master cancelled delivery with remark: " + this.remark : this.thisItem.remark, - LatestStatus: this.thisItem.toOther === "Return" ? "Faulty" : (this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Repair" || this.thisItem.toOther === "On Delivery" ) ? "Ready To Deploy" : "" + Remark: this.thisItem.toOther === "On Delivery" && this.thisItem.toUser == this.currentUser.id ? this.thisItem.remark + ". Inventory Master cancelled delivery with remark: " + this.remark : this.thisItem.remark, + LastUser: this.thisItem.lastuser == null ? this.currentUser.id : this.thisItem.lastuser, + LatestStatus: this.thisItem.toOther === "Return" ? "Faulty" : (this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Repair" || this.thisItem.toOther === "On Delivery" ) ? "Ready To Deploy" : (this.itemlateststatus == 'On Delivery' && this.thisItem.lastStore == this.currentUser.store ? "Delivered" : "") }; @@ -923,9 +945,19 @@ // this.thisItem = await response.json(); this.thisItem = await response.json(); + console.log('last store'+this.thisItem.lastStore); + this.itemlateststatus = this.thisItem.latestStatus ? this.thisItem.latestStatus : this.thisItem.toOther; - this.itemassignedtouser = this.thisItem.toUser == this.currentUser.id || this.thisItem.lastUser == this.currentUser.id ? true : false; + this.itemassignedtouser = (this.thisItem.toUser === this.currentUser.id || this.thisItem.lastUser === this.currentUser.id ) && this.thisItem.lastStore === this.currentUser.store ? true : false; // console.log(this.thisItem); + // console.log(this.itemassignedtouser); + console.log(this.thisItem.lastStore); + console.log( this.thisItem.lastStore == this.currentUser.store? true : false); + console.log(this.thisItem.toUser == this.currentUser.id? true : false); + console.log( this.thisItem.lastUser == this.currentUser.id ? true : false); + console.log(((this.thisItem.toUser == this.currentUser.id) || ( this.thisItem.lastUser == this.currentUser.id)) ? true : false); + console.log('currentuser store'+this.currentUser.store); + } else { console.error('Failed to fetch item information'); diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs index 4afb06a..b78f641 100644 --- a/Controllers/API/Inventory/InvMainAPI.cs +++ b/Controllers/API/Inventory/InvMainAPI.cs @@ -538,6 +538,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory item.Movement?.ToOther, item.Movement?.LatestStatus, item.Movement?.LastUser, + item.Movement?.LastStore, item.Movement?.MovementComplete, remark = item.Movement?.Remark, QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String @@ -736,6 +737,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory return NotFound("Item movement record not found."); } + updatedList.LastUser = receiveMovement.LastUser; updatedList.LatestStatus = receiveMovement.LatestStatus; updatedList.receiveDate = receiveMovement.receiveDate; updatedList.Remark = receiveMovement.Remark; @@ -1216,7 +1218,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory { return NotFound("Item movement record not found."); } - + updatedList.MovementComplete = receiveMovement.MovementComplete; updatedList.LatestStatus = receiveMovement.LatestStatus; updatedList.receiveDate = receiveMovement.receiveDate; updatedList.MovementComplete = receiveMovement.MovementComplete; From ce2a741450c90484693294dfcce1c8b40dc4af80 Mon Sep 17 00:00:00 2001 From: ArifHilmi Date: Mon, 10 Mar 2025 22:28:46 +0800 Subject: [PATCH 02/52] Update Qr --- Areas/Inventory/Models/RequestModel.cs | 2 + .../Views/InventoryMaster/ItemMovement.cshtml | 2 +- .../InventoryMaster/ItemRegistration.cshtml | 42 +- .../InventoryMaster/ItemRequestMaster.cshtml | 956 +++++++++------ .../ManifacturerRegistration.cshtml | 2 +- .../ProductRegistration.cshtml | 2 +- .../StationRegistration.cshtml | 2 +- .../SupplierRegistration.cshtml | 2 +- .../Views/ItemMovement/ItemRequest.cshtml | 2 +- Controllers/API/Inventory/InvMainAPI.cs | 88 ++ ...50310054721_UpdateTableRequest.Designer.cs | 1059 +++++++++++++++++ .../20250310054721_UpdateTableRequest.cs | 68 ++ .../CentralSystemContextModelSnapshot.cs | 18 +- appsettings.json | 2 +- 14 files changed, 1874 insertions(+), 373 deletions(-) create mode 100644 Migrations/20250310054721_UpdateTableRequest.Designer.cs create mode 100644 Migrations/20250310054721_UpdateTableRequest.cs diff --git a/Areas/Inventory/Models/RequestModel.cs b/Areas/Inventory/Models/RequestModel.cs index 66b6628..fdacce9 100644 --- a/Areas/Inventory/Models/RequestModel.cs +++ b/Areas/Inventory/Models/RequestModel.cs @@ -26,6 +26,8 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models public DateTime? approvalDate { get; set; } public int? RequestQuantity { get; set; } public string? Document { get; set; } + public string? fromStoreItem { get; set; } + public string? assignStoreItem { get; set; } } } diff --git a/Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml b/Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml index 12bf185..da045ee 100644 --- a/Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml +++ b/Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml @@ -49,7 +49,7 @@ margin-left: auto !important; /* Push Complete/Incomplete to right */ } -@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml"); +@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml")

Sort by:

diff --git a/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml b/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml index f91c0dc..5f0e183 100644 --- a/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml +++ b/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml @@ -638,18 +638,27 @@ ], responsive: true, drawCallback: function (settings) { - // Generate QR codes after rows are rendered - const api = this.api(); - api.rows().every(function () { - const data = this.data(); // Row data - const containerId = `qr${data.uniqueID}`; - const container = $(`#${containerId}`); - container.empty(); - container.append(`${data.uniqueID}`); - // console.log(container[0]); - if (container) { - // Generate QR code only if not already generated - new QRCode(container[0], { + setTimeout(() => { + const api = this.api(); + api.rows().every(function () { + const data = this.data(); + const containerId = `qr${data.uniqueID}`; + const container = document.getElementById(containerId); + + if (!container) { + return; + } + + container.innerHTML = ""; + container.append(data.uniqueID); + + // Ensure qrString is valid before generating QR code + if (!data.qrString) { + return; + } + + // Generate QR Code + new QRCode(container, { text: data.qrString, width: 100, height: 100, @@ -657,12 +666,9 @@ colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.M }); - } - // container.on('click', function() { - // window.open(data.qrString, '_blank'); - // }); - }); - }, + }); + }, 100); // Small delay to ensure elements exist + } }) // Attach click event listener to the delete buttons diff --git a/Areas/Inventory/Views/InventoryMaster/ItemRequestMaster.cshtml b/Areas/Inventory/Views/InventoryMaster/ItemRequestMaster.cshtml index f06f6c9..8625b70 100644 --- a/Areas/Inventory/Views/InventoryMaster/ItemRequestMaster.cshtml +++ b/Areas/Inventory/Views/InventoryMaster/ItemRequestMaster.cshtml @@ -2,36 +2,129 @@ ViewData["Title"] = "Product Request"; Layout = "~/Views/Shared/_Layout.cshtml"; } -@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml"); +@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml") + +
-
-
-

Pending Request

- @* *@ -
-
- @*
-
- Loading... -
-
*@ -
+
+

Sort by:

+
+
-
-
-

Complete Request

- @* *@ + +
+
+
+

Pending Request Master

+ + +
+
+
+
-
- @*
-
- Loading... -
-
*@ -
+ +
+
+

Pending Approval Request (Your Item)

+
+
+
+
+
+ +
+
+

Complete Request Master

+
+
+
+
+ +
+
+
+

Pending Request

+
+
+
+
+
+ +
+
+

Complete Request

+
+
+
+
+
+
+