@@ -548,6 +563,7 @@
return {
itemMovements: [],
itemMovementCompleteDatatable: null,
+ stationDatatable: null,
itemMovementNotCompleteDatatable: null,
searchQuery: "",
searchStation: "",
@@ -572,28 +588,63 @@
return acc;
}, {});
},
+
groupedByStation() {
let grouped = {};
this.itemMovements.forEach((movement) => {
- let station = movement.toStationName || movement.lastStationName || "Unassign Station";
- let itemId = movement.uniqueID;
- if (!grouped[station]) {
- grouped[station] = {};
+ if (movement.toStation !== null) {
+ let station = movement.toStationName;
+ let itemId = movement.uniqueID;
+
+ if (!grouped[station]) {
+ grouped[station] = {};
+ }
+
+ if (!grouped[station][itemId]) {
+ grouped[station][itemId] = { uniqueID: itemId, movements: [] };
+ }
+
+ grouped[station][itemId].movements.push(movement);
}
- if (!grouped[station][itemId]) {
- grouped[station][itemId] = { uniqueID: itemId, movements: [] };
- }
+ if (movement.lastStation !== null) {
+ let station = movement.lastStationName;
+ let itemId = movement.uniqueID;
- grouped[station][itemId].movements.push(movement);
+ if (!grouped[station]) {
+ grouped[station] = {};
+ }
+
+ if (!grouped[station][itemId]) {
+ grouped[station][itemId] = { uniqueID: itemId, movements: [] };
+ }
+
+ grouped[station][itemId].movements.push(movement);
+ }
+ else if (movement.lastStation == null || movement.toStation == null) {
+
+ let station = "Self";
+ let itemId = movement.uniqueID;
+
+ if (!grouped[station]) {
+ grouped[station] = {};
+ }
+
+ if (!grouped[station][itemId]) {
+ grouped[station][itemId] = { uniqueID: itemId, movements: [] };
+ }
+
+ grouped[station][itemId].movements.push(movement);
+ }
+
});
// Sort stations and move "Unassign Station" to the last position
let sortedKeys = Object.keys(grouped).sort((a, b) => {
- if (a === "Unassign Station") return 1; // Move Unassign Station to the end
+ if (a === "Unassign Station") return 1;
if (b === "Unassign Station") return -1;
- return a.localeCompare(b); // Normal sorting for other stations
+ return a.localeCompare(b);
});
let sortedGrouped = {};
@@ -603,6 +654,7 @@
return sortedGrouped;
},
+
filteredItems() {
if (!this.searchQuery.trim()) {
return this.groupedItems;
@@ -614,6 +666,7 @@
)
);
},
+
filteredStation() {
if (!this.searchStation) {
return this.groupedByStation;
@@ -684,6 +737,7 @@
this.initAllTables();
}
},
+
initAllTables() {
if (this.itemMovementNotCompleteDatatable) {
this.itemMovementNotCompleteDatatable.destroy();
@@ -691,20 +745,23 @@
if (this.itemMovementCompleteDatatable) {
this.itemMovementCompleteDatatable.destroy();
}
+ if(this.stationDatatable) {
+ this.stationDatatable.destroy();
+ }
this.itemMovementNotCompleteDatatable = $("#itemMovementNotCompleteDatatable").DataTable({
data: this.itemMovements.filter((m) => m.movementComplete == 0),
columns: [
{ title: "Unique Id", data: "id" },
{ title: "Product Code", data: "uniqueID" },
+ { title: "Action", data: "action" },
+ { title: "Send Date", data: "sendDate" },
{ title: "From User", data: "toUserName" },
{ title: "Last User", data: "lastUserName" },
{ title: "From Station", data: "toStationName" },
{ title: "From Store", data: "toStoreName" },
- { title: "Action", data: "action" },
{ title: "Start Status", data: "toOther" },
{ title: "Quantity", data: "quantity" },
- { title: "Send Date", data: "sendDate" },
{
title: "Note",
data: "consignmentNote",
@@ -740,22 +797,22 @@
});
this.itemMovementCompleteDatatable = $("#itemMovementCompleteDatatable").DataTable({
- data: this.itemMovements.filter((m) => m.movementComplete == 1),
+ data: this.itemMovements.filter((m) => m.movementComplete == 1 && m.action !== "Assign"),
columns: [
{ title: "Unique Id", data: "id" },
{ title: "Product Code", data: "uniqueID" },
+ { title: "Send Date", data: "sendDate" },
+ { title: "Receive Date", data: "receiveDate" },
+ { title: "Action", data: "action" },
{ title: "From User", data: "toUserName" },
{ title: "Last User", data: "lastUserName" },
{ title: "From Station", data: "toStationName" },
{ title: "Last Station", data: "lastStationName" },
{ title: "From Store", data: "toStoreName" },
{ title: "Last Store", data: "lastStoreName" },
- { title: "Action", data: "action" },
{ title: "Start Status", data: "toOther" },
{ title: "Latest Status", data: "latestStatus" },
{ title: "Qty", data: "quantity" },
- { title: "Send Date", data: "sendDate" },
- { title: "Receive Date", data: "receiveDate" },
{ title: "Note",
data: "consignmentNote",
render: function (data, type, full, meta) {
@@ -788,16 +845,64 @@
],
responsive: true,
});
+
+ this.stationDatatable = $("#stationDatatable").DataTable({
+ data: this.itemMovements.filter((m) => m.action === "Assign" ),
+ columns: [
+ { title: "Unique Id", data: "id" },
+ { title: "Product Code", data: "uniqueID" },
+ { title: "Assign Date", data: "sendDate" },
+ { title: "From User", data: "toUserName" },
+ { title: "From Station", data: "toStationName" },
+ { title: "Last Station", data: "lastStationName" },
+ { title: "Qty", data: "quantity" },
+ {
+ title: "Note",
+ data: "consignmentNote",
+ render: function (data, type, full, meta) {
+ if (!data) {
+ return "No Document";
+ }
+
+ // Check if the document is an image based on file extension
+ var isImage = /\.(jpeg|jpg|png|gif)$/i.test(data);
+ var isPdf = /\.pdf$/i.test(data);
+
+ if (isImage) {
+ return `
+
+ `;
+ }
+ else if (isPdf) {
+ return `
+
+
View PDF
+ `;
+ } else {
+ return `
Download File`;
+ }
+ },
+ },
+ { title: "Remark", data: "remark" },
+ ],
+ responsive: true,
+ });
},
+
toggleCategory(itemId) {
this.categoryVisible[itemId] = !this.categoryVisible[itemId];
},
+
toggleHistory(itemId) {
this.historyVisible[itemId] = !this.historyVisible[itemId];
},
+
toggleDetails(movementId) {
this.detailsVisible[movementId] = !this.detailsVisible[movementId];
},
+
handleSorting() {
this.renderTables();
},
diff --git a/Areas/Inventory/Views/ItemMovement/QrUser.cshtml b/Areas/Inventory/Views/ItemMovement/QrUser.cshtml
index 93cf6c5..7417ad2 100644
--- a/Areas/Inventory/Views/ItemMovement/QrUser.cshtml
+++ b/Areas/Inventory/Views/ItemMovement/QrUser.cshtml
@@ -261,6 +261,19 @@