From 2c10b891477a05fd0161356c16bc9174683d3768 Mon Sep 17 00:00:00 2001 From: ameerulrasyid Date: Fri, 14 Mar 2025 07:29:25 +0800 Subject: [PATCH] small fix --- .../Views/InventoryMaster/ItemMovement.cshtml | 79 +++++++------------ Controllers/API/Inventory/InvMainAPI.cs | 22 +++--- 2 files changed, 41 insertions(+), 60 deletions(-) diff --git a/Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml b/Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml index da045ee..7a79775 100644 --- a/Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml +++ b/Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml @@ -118,7 +118,8 @@

Item Movement List

-
+
@@ -131,7 +132,9 @@
-

Item : {{ group.uniqueID }}

+ @*

Item : {{ group.uniqueID }}

*@ +

Item : {{ group.uniqueID }}

+

Item : No Item Tracked

@@ -250,7 +253,10 @@ 'text-weird': movement.action === 'Register'}" class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;"> - {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }} + {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : + ( movement.toStation !== null ? 'Change' : + ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : + ( movement.action == 'Register' ? 'Register' : 'Assign')))) }} @@ -283,9 +289,13 @@ -

- {{ movement.action == 'Register' ? 'Complete' : (movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete'))) }} + {{ movement.action == 'Register' ? 'Complete' : + (movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : + ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : + (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete'))) }}

@@ -341,7 +351,8 @@
-
+

{{ station }}

@@ -355,7 +366,9 @@
-

Item : {{ group.uniqueID }}

+ @*

Item : {{ group.uniqueID }}

*@ +

Item : {{ group.uniqueID }}

+

Item : No Item Tracked

@@ -664,26 +677,13 @@ return acc; }, {}); - console.log(grouped); - // Sort items from newest to oldest & filter them for (let itemId in grouped) { let movements = grouped[itemId].movements .sort((a, b) => b.id - a.id); // Newest to oldest - // console.log(movements); - // let stopIndex = movements.findIndex(m => - // m.toOther === 'Return' && m.movementComplete == 1 - // ); - - // if (stopIndex !== -1) { - // movements = movements.slice(0, stopIndex + 1); - // } - // Ensure at least 3 movements before stopping - let stopIndex = movements.slice(3).findIndex(m => - m.toOther === 'Return' && m.movementComplete == 1 - ); + let stopIndex = movements.slice(3).findIndex(m => m.toOther === 'Return' && m.movementComplete == 1); if (stopIndex !== -1) { stopIndex += 3; // Adjust index since we sliced after the first 3 @@ -692,7 +692,6 @@ grouped[itemId].movements = movements; } - return grouped; }, @@ -716,9 +715,7 @@ .sort((a, b) => b.id - a.id); // Newest → Oldest // Ensure at least 3 movements before stopping - let stopIndex = movements.slice(3).findIndex(m => - m.toOther === 'Return' && m.movementComplete == 1 - ); + let stopIndex = movements.slice(3).findIndex(m => m.toOther === 'Return' && m.movementComplete == 1); // Remove older movements if (stopIndex !== -1) { @@ -730,9 +727,7 @@ let latestMovement = movements[0]; let station = latestMovement.lastStationName || latestMovement.toStationName || "Not Assigned"; - if (!groupedByStation[station]) { - groupedByStation[station] = {}; - } + if (!groupedByStation[station]) { groupedByStation[station] = {}; } groupedByStation[station][itemId] = { uniqueID: itemId, movements }; } @@ -752,8 +747,6 @@ return sortedGrouped; - - }, filteredItems() { if (!this.searchQuery.trim()) { @@ -766,7 +759,7 @@ ) ); - }, + }, filteredStation() { if (!this.searchStation) { return this.groupedByStation; @@ -781,10 +774,8 @@ filtered[station] = grouped[station]; } }); - - return filtered; - - }, + return filtered; + }, }, methods: { @@ -914,8 +905,6 @@ } if(this.currentRole == "Super Admin"){ this.items = await response.json(); - - console.log(this.items); this.initAllTables(); } else { @@ -929,10 +918,6 @@ this.initAllTables(); - - // console.log(this.items); - - } if (this.itemDatatable) { @@ -982,16 +967,10 @@ this.renderTables(); }, renderTables() { - // if (this.sortBy === "logs") { - // // this.initAllTables(); - // this.initiateTable(); - // } else - // if (this.sortBy === "all") { - // this.initAllTables(); - // // this.initiateTable(); - // } - this.initAllTables(); + this.initAllTables(); + this.initiateTable(); + }, initAllTables() { if (this.itemMovementNotCompleteDatatable) { diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs index 5b7e9c1..0fab0fd 100644 --- a/Controllers/API/Inventory/InvMainAPI.cs +++ b/Controllers/API/Inventory/InvMainAPI.cs @@ -591,16 +591,18 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory .Include(i => i.NextUser) .ToListAsync(); - int itemrow = 0; - var itemMovementListWithQR = itemMovementList.Select(item => new - { - id = itemrow++, - item, // Includes all properties of the original item - QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.ItemId}", // Generate QR String - ProductName = item.Item?.Product?.ProductName, - toUserName = item.NextUser?.FullName, - lastUserName = item.FromUser?.FullName - }).ToList(); + // if use qr, need to use this. else do simple return json. datatable qr will read dom and replace element with id=qr{qrstring} with qr image. + // then need dynamic numbering for qr even if item movement is repeated by the same item + //int itemrow = 0; + //var itemMovementListWithQR = itemMovementList.Select(item => new + //{ + // id = itemrow++, + // item, // Includes all properties of the original item + // QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.ItemId}", // Generate QR String + // ProductName = item.Item?.Product?.ProductName, + // toUserName = item.NextUser?.FullName, + // lastUserName = item.FromUser?.FullName + //}).ToList(); //Console.WriteLine(Json(itemMovementListWithQR));