@@ -804,6 +804,19 @@
showSerialNumber() {
return this.showProduct.category === 'Asset' || this.showProduct.category === 'Part';
},
+ filteredStationList() {
+ if (!this.stationlist || !this.currentUser) return [];
+
+ return this.stationlist.filter(station => {
+ // Check 1: Must match User's Department
+ // const isSameDept = station.departmentId === this.selectedDepartment;
+
+ // Check 2: Must match User's ID as the Station PIC
+ const isPIC = station.stationPicID === this.currentUser.id;
+
+ return isPIC;
+ });
+ },
},
methods: {
// Split Url dapatkan unique ID Je
@@ -960,11 +973,20 @@
const now = new Date();
const formData = {
- ...(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, 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, } : {}),
+ ...(this.selectedAction === 'user' ? { lastStore: this.currentUser.store, lastUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, toUser: this.selectedUser, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}),
+ ...(this.selectedAction === 'station' ? {
+ lastStore: this.currentUser.store,
+ lastUser: this.currentUser.id,
+ toOther: 'On Delivery',
+ SendDate: this.assigndate,
+ toStation: this.selectedStation,
+ toUser: this.selectedStationPIC,
+ MovementComplete: false,
+ Remark: this.remark,
+ ConsignmentNote: this.document} : {}),
+ ...(this.selectedAction === 'store' ? { lastStore: this.currentUser.store, lastUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, toStore: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}),
+ ...(this.selectedAction === 'supplier' ? { lastStore: this.currentUser.store, lastUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther, ConsignmentNote: this.document, toUser: this.currentUser.id, toStore: this.currentUser.store, MovementComplete: false, } : {}),
+ ...(this.selectedAction === 'faulty' ? { lastStore: this.currentUser.store, lastUser: 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',
@@ -1012,11 +1034,13 @@
// Determine the status based on specific conditions
let statusToSave = "";
- // 1. YOUR NEW LOGIC: If it's On Delivery and the current user is the target lastUser, set to Delivered
- if (this.thisItem.toOther === "On Delivery" && this.thisItem.lastUser == this.currentUser.id) {
- statusToSave = "Delivered";
- }
- // 2. KEEP EXISTING LOGIC: Calibration/Repair/Return/General Delivery goes to Ready to Deploy
+ // If it's On Delivery and the current user/store is the target toUser/toStore, set to Delivered
+ if (this.thisItem.toOther === "On Delivery" &&
+ (this.thisItem.toUser == this.currentUser.id || this.thisItem.toStore == this.currentUser.store))
+ {
+ statusToSave = "Delivered";
+ }
+ // Calibration/Repair/Return/General Delivery goes to Ready to Deploy
else if (
this.thisItem.toOther === "Return" ||
this.thisItem.toOther === "Calibration" ||
@@ -1025,16 +1049,13 @@
) {
statusToSave = "Ready To Deploy";
}
- // 3. KEEP EXISTING LOGIC: Store-to-Store delivery check
- else if (this.itemlateststatus == 'On Delivery' && this.thisItem.lastStore == this.currentUser.store) {
- statusToSave = "Delivered";
- }
const formData = {
Id: this.thisItem.movementId,
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
Remark: this.thisItem.remark,
- LastUser: this.thisItem.lastuser == null ? this.currentUser.id : this.thisItem.lastuser,
+ ToUser: this.thisItem.touser == null ? this.currentUser.id : this.thisItem.touser,
+ ToStore: this.currentUser.store,
LatestStatus: statusToSave // Uses the prioritized status from above
};
@@ -1075,11 +1096,12 @@
this.itemlateststatus = this.thisItem.latestStatus ? this.thisItem.latestStatus : this.thisItem.toOther;
this.itemassignedtouser = (
- (this.thisItem.toStore === this.currentUser.store || this.thisItem.lastStore === this.currentUser.store)
- && this.currentUser.store != null
+ this.thisItem.departmentId === this.selectedDepartment &&
+ this.selectedDepartment != null &&
+ this.selectedDepartment !== ""
);
// Debugging logs to help you verify in the browser console
- console.log('Item Store ID:', this.thisItem.toStore);
+ console.log('Item Store ID:', this.thisItem.lastStore);
console.log('User Master Store ID:', this.currentUser.store);
console.log('Is User Authorized Master for this item?', this.itemassignedtouser);
@@ -1151,16 +1173,16 @@
// Second Movement: Re-registration/Re-stock Record
const registrationMovementData = {
ItemId: this.thisItem.itemID,
- ToStore: this.currentUser.store,
- ToUser: this.currentUser.id,
+ LastStore: this.currentUser.store,
+ LastUser: this.currentUser.id,
ToOther: null,
sendDate: null,
Action: 'Register',
Quantity: this.thisItem.movementQuantity,
Remark: null,
ConsignmentNote: null,
- LastUser: this.currentUser.id,
- LastStore: this.currentUser.store,
+ ToUser: this.currentUser.id,
+ ToStore: this.currentUser.store,
LatestStatus: 'Ready To Deploy',
receiveDate: null,
MovementComplete: true,
@@ -1320,20 +1342,39 @@
const now = new Date();
const formData = {
- ItemId: this.thisItem.itemID,
- ToStore: this.thisItem.toStore,
- ToUser: this.thisItem.toUser, // This will be handled by the API logic
- ToOther: "Return",
- SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
- Action: "StockIn",
- Quantity: this.thisItem.quantity || 1,
- Remark: this.remark + " (Returned)",
- ConsignmentNote: this.document, // The base64 string from handleFileUpload
- Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
- LastUser: this.currentUser.id,
- LastStore: this.thisItem.toStore,
- LatestStatus: null,
- MovementComplete: false
+ // ItemId: this.thisItem.itemID,
+ // LastStore: this.thisItem.lastStore,
+ // LastUser: this.thisItem.lastUser, This will be handled by the API logic
+ // ToOther: "Return",
+ // SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
+ // Action: "StockIn",
+ // Quantity: this.thisItem.quantity || 1,
+ // Remark: this.remark + " (Returned)",
+ // ConsignmentNote: this.document, The base64 string from handleFileUpload
+ // Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
+ // ToUser: this.currentUser.id,
+ // ToStore: this.thisItem.lastStore,
+ // LatestStatus: null,
+ // MovementComplete: false
+
+ ItemId: this.thisItem.itemID,
+ LastStation: this.thisItem.currentStationId,
+ LastStore: this.thisItem.currentStoreId,
+ LastUser: this.currentUser.id,
+ ToOther: "Return",
+ SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
+ Action: "StockIn",
+ // Quantity: this.thisItem.quantity,
+ Quantity: this.thisItem.movementQuantity || 1,
+ Remark: this.remark,
+ ConsignmentNote: this.consignmentNote,
+ Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
+ ToUser: this.thisItem.lastUser,
+ ToStore: this.thisItem.lastStore,
+ // ToStation: this.thisItem.lastStation,
+ LatestStatus: null,
+ ReceiveDate: null,
+ MovementComplete: false,
};
try {
@@ -1373,9 +1414,9 @@
const now = new Date();
const formData = {
ItemId: this.thisItem.itemID,
- ToStation: this.thisItem.ToStation,
- ToStore: this.thisItem.toStore,
- ToUser: this.currentUser.id,
+ LastStation: this.thisItem.lastStation || this.thisItem.currentStationId || null,
+ LastStore: this.currentUser.store,
+ LastUser: this.currentUser.id,
ToOther: "Delivered",
SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
Action: "Assign",
@@ -1383,9 +1424,9 @@
Remark: this.remark || "Deployed to station",
ConsignmentNote: this.document, // Base64 from file upload
Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
- LastUser: this.currentUser.id,
- LastStore: this.thisItem.toStore,
- LastStation: this.selectedStation, // The new station ID selected in modal
+ ToUser: this.currentUser.id,
+ ToStore: this.currentUser.store,
+ ToStation: this.selectedStation, // The new station ID selected in modal
LatestStatus: "Delivered",
receiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
MovementComplete: true
diff --git a/Areas/Inventory/Views/ItemMovement/ItemMovementUser.cshtml b/Areas/Inventory/Views/ItemMovement/ItemMovementUser.cshtml
index 251a6e6..655fb5f 100644
--- a/Areas/Inventory/Views/ItemMovement/ItemMovementUser.cshtml
+++ b/Areas/Inventory/Views/ItemMovement/ItemMovementUser.cshtml
@@ -172,10 +172,10 @@
Latest Movement
- {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : 'Assign')) }}
+ {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : 'Assign')) }}
@@ -220,13 +220,13 @@
-
+
Start
-
User: {{ movement.toUserName }}
-
Station: {{ movement.toStationName }}
-
Store: {{ movement.toStoreName }}
+
User: {{ movement.lastUserName }}
+
Station: {{ movement.lastStationName }}
+
Store: {{ movement.lastStoreName }}
-
+
End
-
User: {{ movement.lastUserName }}
-
Station: {{ movement.lastStationName }}
-
Store: {{ movement.lastStoreName }}
+
User: {{ movement.toUserName }}
+
Station: {{ movement.toStationName }}
+
Store: {{ movement.toStoreName }}
@@ -267,10 +267,10 @@
- {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : 'Assign')) }}
+ {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : 'Assign')) }}
@@ -314,13 +314,13 @@
-
+
Start
-
User: {{ movement.toUserName }}
-
Station: {{ movement.toStationName }}
-
Store: {{ movement.toStoreName }}
+
User: {{ movement.lastUserName }}
+
Station: {{ movement.lastStationName }}
+
Store: {{ movement.lastStoreName }}
-
+
End
-
User: {{ movement.lastUserName }}
-
Station: {{ movement.lastStationName }}
-
Store: {{ movement.lastStoreName }}
+
User: {{ movement.toUserName }}
+
Station: {{ movement.toStationName }}
+
Store: {{ movement.toStoreName }}
@@ -388,10 +388,10 @@
Latest Movement
- {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : 'Assign')) }}
+ {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : 'Assign')) }}
@@ -434,13 +434,13 @@
-
+
Start
-
User: {{ movement.toUserName }}
-
Station: {{ movement.toStationName }}
-
Store: {{ movement.toStoreName }}
+
User: {{ movement.lastUserName }}
+
Station: {{ movement.lastStationName }}
+
Store: {{ movement.lastStoreName }}
@@ -457,13 +457,13 @@
-
+
End
-
User: {{ movement.lastUserName }}
-
Station: {{ movement.lastStationName }}
-
Store: {{ movement.lastStoreName }}
+
User: {{ movement.toUserName }}
+
Station: {{ movement.toStationName }}
+
Store: {{ movement.toStoreName }}
@@ -480,10 +480,10 @@
- {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : 'Assign')) }}
+ {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : 'Assign')) }}
@@ -529,13 +529,13 @@
-
+
Start
-
User: {{ movement.toUserName }}
-
Station: {{ movement.toStationName }}
-
Store: {{ movement.toStoreName }}
+
User: {{ movement.lastUserName }}
+
Station: {{ movement.lastStationName }}
+
Store: {{ movement.lastStoreName }}
-
+
End
-
User: {{ movement.lastUserName }}
-
Station: {{ movement.lastStationName }}
-
Store: {{ movement.lastStoreName }}
+
User: {{ movement.toUserName }}
+
Station: {{ movement.toStationName }}
+
Store: {{ movement.toStoreName }}
@@ -761,7 +761,7 @@
if (movements.length > 0) {
let latestMovement = movements[0];
- let station = latestMovement.lastStationName || latestMovement.toStationName || "Self Assigned";
+ let station = latestMovement.toStationName || latestMovement.lastStationName || "Self Assigned";
if (!groupedByStation[station]) {
groupedByStation[station] = {};
@@ -1037,10 +1037,10 @@
{ title: "Action", data: "action" },
{ title: "Send Date", data: "sendDate", render: this.formatDate.bind(this) },
{ title: "Start Status", data: "toOther" },
- { title: "From User", data: "toUserName" },
- { title: "Last User", data: "lastUserName" },
- { title: "From Station", data: "toStationName" },
- { title: "From Store", data: "toStoreName" },
+ { title: "From User", data: "lastUserName" },
+ { title: "Last User", data: "toUserName" },
+ { title: "From Station", data: "lastStationName" },
+ { title: "From Store", data: "lastStoreName" },
{ title: "Quantity", data: "quantity" },
{ title: "Note", data: "consignmentNote", render: renderFile },
{ title: "Remark", data: "remark" },
@@ -1055,17 +1055,17 @@
{ title: "Unique Id", data: "id" },
{ title: "Product Name", data: "productName", render: (data, type, full) => { return `${data}
${renderFile(full.productImage)}`; } },
{ title: "Product Code", data: "uniqueID" },
- { title: "Send Date", data: "sendDate", render: this.formatDate.bind(this) },
- { title: "Receive Date", data: "receiveDate", render: this.formatDate.bind(this) },
+ { title: "Send Date", data: "sendDate", render: this.formatDate.bind(this) },
+ { title: "Receive Date", data: "receiveDate", render: this.formatDate.bind(this) },
{ title: "Action", data: "action" },
{ title: "Start Status", data: "toOther" },
{ title: "Latest Status", data: "latestStatus" },
- { 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: "From User", data: "lastUserName" },
+ { title: "Last User", data: "toUserName" },
+ { title: "From Station", data: "lastStationName" },
+ { title: "Last Station", data: "toStationName" },
+ { title: "From Store", data: "lastStoreName" },
+ { title: "Last Store", data: "toStoreName" },
{ title: "Qty", data: "quantity" },
{ title: "Note", data: "consignmentNote", render: renderFile },
{ title: "Remark", data: "remark" },
@@ -1082,9 +1082,9 @@
{ title: "Product Code", data: "uniqueID" },
{ title: "Assign Date", data: "sendDate", render: this.formatDate.bind(this) },
{ title: "Action", data: "action" },
- { title: "Station User PIC", data: "toUserName" },
- { title: "From Station", data: "toStationName" },
- { title: "Last Station", data: "lastStationName" },
+ { title: "Station User PIC", data: "lastUserName" },
+ { title: "From Station", data: "lastStationName" },
+ { title: "Last Station", data: "toStationName" },
{ title: "Qty", data: "quantity" },
{ title: "Note", data: "consignmentNote", render: renderFile },
{ title: "Remark", data: "remark" },
diff --git a/Areas/Inventory/Views/ItemMovement/QrUser.cshtml b/Areas/Inventory/Views/ItemMovement/QrUser.cshtml
index c874f73..9734ba5 100644
--- a/Areas/Inventory/Views/ItemMovement/QrUser.cshtml
+++ b/Areas/Inventory/Views/ItemMovement/QrUser.cshtml
@@ -54,11 +54,11 @@
-
+
Item Receive Information :
Station Assign
-
+
Item Receive Information :
Self Assign
@@ -220,7 +220,9 @@
@@ -236,7 +238,9 @@