+
@@ -248,6 +248,7 @@
@@ -371,6 +372,7 @@
consignmentNote: null,
receiveReturn: null,
UniqueID: null,
+ InventoryMasterId: null,
//QR VARIABLE
qrCodeResult: null,
@@ -399,10 +401,12 @@
selectedCameraId: null,
};
},
- mounted() {
+ async mounted() {
this.trackFunctionSelected.value = this.paintOutline;
- this.fetchStation();
- this.fetchUser();
+ await this.fetchUser();
+ await Promise.all([
+ this.fetchStation(),
+ ]);
},
methods: {
@@ -435,7 +439,7 @@
const formData = {
ItemId: this.thisItem.itemID,
ToStation: this.thisItem.currentStationId,
- ToStore: this.thisItem.currentStoreId,
+ ToStore: this.thisItem.toStore,
ToUser: this.currentUserId,
ToOther: "Delivered",
SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
@@ -461,10 +465,11 @@
});
if (response.ok) {
+ this.thisItem = await response.json();
+ this.fetchItem(this.thisItem.uniqueID);
alert('Success! Item assign to the Station.');
$('#stationMessage').modal('hide');
this.displayStatus = "return";
- this.thisItem = await response.json();
} else {
throw new Error('Failed to submit form.');
}
@@ -488,7 +493,7 @@
Id : this.thisItem.id,
LatestStatus: "Delivered",
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
- MovementComplete: true
+ MovementComplete: true,
};
const response = await fetch('/InvMainAPI/UpdateItemMovementUser', {
@@ -520,14 +525,14 @@
async returnItemMovement() {
- const requiredFields = ['remark', 'consignmentNote'];
+ // const requiredFields = ['remark', 'consignmentNote'];
- for (let field of requiredFields) {
- if (!this[field]) {
- alert(`Request Error: Please fill in required field ${field}.`, 'warning');
- return;
- }
- }
+ // for (let field of requiredFields) {
+ // if (!this[field]) {
+ // alert(`Request Error: Please fill in required field ${field}.`, 'warning');
+ // return;
+ // }
+ // }
if (!confirm("Are you sure you want to return this item?")) {
return false;
@@ -547,7 +552,7 @@
Remark: this.remark,
ConsignmentNote: this.consignmentNote,
Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
- LastUser: this.thisItem.toUser,
+ LastUser: this.InventoryMasterId,
LastStore: this.thisItem.toStore,
LastStation: this.thisItem.toStation,
LatestStatus: null,
@@ -567,6 +572,7 @@
alert('Success! Item is on the delivery to return to Inventory Master.');
this.thisItem = await response.json();
$('#returnModal').modal('hide');
+ $('#returnMessage').modal('hide');
this.displayStatus = "requestAgain";
this.resetForm();
} else {
@@ -585,7 +591,9 @@
);
if (response.ok) {
+
this.thisItem = await response.json();
+ this.fetchStore(this.thisItem.toStore);
if (this.thisItem.movementId != null && this.thisItem.toOther === "On Delivery" && this.thisItem.latestStatus == null && this.thisItem.currentUserId == this.currentUserId && this.thisItem.movementComplete == 0) {
this.displayStatus = "arrived";
@@ -616,7 +624,28 @@
if (!response.ok) {
throw new Error('Failed to fetch suppliers');
}
- this.stationList = await response.json(); // Get the full response object
+
+ const data = await response.json();
+ this.stationList = data.filter(station => station.stationPicID === this.currentUserId);
+ } catch (error) {
+ console.error('Error fetching suppliers:', error);
+ }
+ },
+
+ async fetchStore(storeId) {
+ try {
+ const response = await fetch('/InvMainAPI/StoreSpecificMaster/' + storeId, {
+ method: 'POST', // Specify the HTTP method
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ });
+ if (!response.ok) {
+ throw new Error('Failed to fetch Store');
+ }
+
+ const data = await response.json();
+ this.InventoryMasterId = data.userId;
} catch (error) {
console.error('Error fetching suppliers:', error);
diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs
index 72976b2..9e510d6 100644
--- a/Controllers/API/Inventory/InvMainAPI.cs
+++ b/Controllers/API/Inventory/InvMainAPI.cs
@@ -1173,6 +1173,12 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return Json(storeList);
}
+ [HttpPost("StoreSpecificMaster/{storeId}")]
+ public async Task
StoreSpecificMaster(int storeId)
+ {
+ var storeList = await _centralDbContext.InventoryMasters.Where(i => i.StoreId == storeId).FirstOrDefaultAsync();
+ return Json(storeList);
+ }
#endregion Store
@@ -1282,10 +1288,20 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
returnItems.ItemStatus = 2;
_centralDbContext.Items.Update(returnItems);
- await _centralDbContext.SaveChangesAsync(); // Simpan perubahan
}
}
+ //4. Update Assign Row (Untuk ToStore = Ada value , kepada , ToStore = null)
+ var updateToStoreAssignStation = await _centralDbContext.ItemMovements.Where(i => i.Action == "Assign").ToListAsync();
+
+ foreach (var item in updateToStoreAssignStation)
+ {
+ item.ToStore = null; // Set ToStore to null for each matching row
+ _centralDbContext.ItemMovements.Update(item);
+ }
+
+ await _centralDbContext.SaveChangesAsync(); // Simpan perubahan
+
return Json(new
{
updateItemIdMovement.Id,
@@ -1355,7 +1371,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
await _centralDbContext.SaveChangesAsync();
// 2. Cari item movement yang ada ItemId & MovementComplete = false
- var updateItemIdMovement = await _centralDbContext.ItemMovements
+ var updateItemIdMovement = await _centralDbContext.ItemMovements.Include(i => i.Item)
.FirstOrDefaultAsync(m => m.Id == stationMovement.Id);
@@ -1368,9 +1384,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{
returnItems.MovementId = updateItemIdMovement.Id;
returnItems.ItemStatus = 3;
- _centralDbContext.Items.Update(returnItems);
- await _centralDbContext.SaveChangesAsync(); // Simpan perubahan
+ _centralDbContext.Items.Update(returnItems); // Simpan perubahan
+ await _centralDbContext.SaveChangesAsync();
}
}
@@ -1378,6 +1394,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{
updateItemIdMovement.Id,
updateItemIdMovement.ItemId,
+ updateItemIdMovement.Item?.UniqueID,
updateItemIdMovement.ToStation,
updateItemIdMovement.ToStore,
updateItemIdMovement.ToUser,