Merge branch 'Dev2' of https://git.pstw.com.my/catalyx/PSTW_CentralizeSystem into Dev2
This commit is contained in:
commit
788ab1aa5a
@ -227,6 +227,11 @@
|
||||
"title": "Product Name",
|
||||
"data": "productName",
|
||||
},
|
||||
{
|
||||
"title": "User ID",
|
||||
"data": "userName",
|
||||
},
|
||||
|
||||
{
|
||||
"title": "Product Category",
|
||||
"data": "productCategory",
|
||||
@ -268,10 +273,10 @@
|
||||
"title": "User Remark",
|
||||
"data": "remarkUser",
|
||||
},
|
||||
{
|
||||
"title": "InvMaster Remark",
|
||||
"data": "remarkMasterInv",
|
||||
},
|
||||
// {
|
||||
// "title": "InvMaster Remark",
|
||||
// "data": "remarkMasterInv",
|
||||
// },
|
||||
{
|
||||
"title": "Status",
|
||||
"data": "status",
|
||||
|
||||
@ -128,6 +128,7 @@
|
||||
<option class="btn-light" value="store">Assign to Store</option>
|
||||
<option class="btn-light" value="supplier">Assign to Supplier</option>
|
||||
<option class="btn-light" value="faulty">Faulty</option>
|
||||
<option class="btn-light" value="receive" hidden>Receive</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -301,10 +302,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div v-if="selectedAction === 'receive'">
|
||||
<form v-on:submit.prevent="receiveItemMovement" data-aos="fade-right">
|
||||
<div class="row register-form">
|
||||
|
||||
<div style="display: flex; justify-content: center; margin-top: 20px;">
|
||||
<button type="submit" class="btn btn-primary" style="width: 200px; padding: 10px; font-size: 16px;">
|
||||
Receive
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -374,7 +393,7 @@
|
||||
this.startScanner();
|
||||
this.fetchUsers();
|
||||
this.fetchStores();
|
||||
// this.fetchItem('ARA00500008'); for testing only. clear this
|
||||
//this.fetchItem('ARA00500008'); // for testing only. clear this
|
||||
},
|
||||
computed: {
|
||||
filteredDepartments() {
|
||||
@ -419,18 +438,18 @@
|
||||
const now = new Date();
|
||||
const formData = {
|
||||
|
||||
...(this.selectedAction === 'user' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false, } : {}),
|
||||
...(this.selectedAction === 'store' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedStore, MovementComplete: false,} : {}),
|
||||
...(this.selectedAction === 'supplier' ? { toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther,lastUser: this.currentUser.id, MovementComplete: false, } : {}),
|
||||
...(this.selectedAction === 'faulty' ? { 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 === 'user' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false,} : {}),
|
||||
...(this.selectedAction === 'store' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedStore, MovementComplete: false, ItemId: this.thisItem.itemID, Action: 'Stock Out', Quantity: 1,} : {}),
|
||||
...(this.selectedAction === 'supplier' ? { toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther,lastUser: this.currentUser.id, MovementComplete: false, ItemId: this.thisItem.itemID, Action: 'Stock Out', Quantity: 1, } : {}),
|
||||
...(this.selectedAction === 'faulty' ? { toUser: this.currentUser.id,toOther: 'Faulty', Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, ItemId: this.thisItem.itemID, Action: 'Stock Out', Quantity: 1,} : {}),
|
||||
|
||||
ItemId: this.thisItem.itemID,
|
||||
Action: 'Stock Out',
|
||||
Quantity: 1,
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
try {
|
||||
|
||||
// Proceed to send the data to the API
|
||||
@ -464,11 +483,61 @@
|
||||
alert('Inventory PSTW Error', `An error occurred: ${error.message}`, 'error');
|
||||
}
|
||||
|
||||
},
|
||||
async receiveItemMovement() {
|
||||
|
||||
if (this.showProduct.category == "Disposable") {
|
||||
this.serialNumber = "";
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const formData = {
|
||||
|
||||
Id: this.thisItem.movementId,
|
||||
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
try {
|
||||
|
||||
// Proceed to send the data to the API
|
||||
const response = await fetch('/InvMainAPI/UpdateItemMovementMaster', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
// 'Authorization': `Bearer ${this.token}`
|
||||
},
|
||||
body: JSON.stringify(formData)
|
||||
});
|
||||
if (response.ok) {
|
||||
// If the form submission was successful, display a success message
|
||||
alert('Success!', 'Item form has been successfully submitted.', 'success');
|
||||
const updatedItem = await response.json();
|
||||
// this.items.push(updatedItem);
|
||||
console.log(updatedItem);
|
||||
|
||||
// Reset the form
|
||||
this.resetForm();
|
||||
window.location.href = '/Inventory/InventoryMaster/ItemMovement';
|
||||
|
||||
} else {
|
||||
throw new Error('Failed to submit form.');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
|
||||
// Displaying error message
|
||||
alert('Inventory PSTW Error', `An error occurred: ${error.message}`, 'error');
|
||||
}
|
||||
|
||||
},
|
||||
startScanner() {
|
||||
const config = {
|
||||
fps: 60,
|
||||
qrbox: 200
|
||||
qrbox: 400
|
||||
};
|
||||
|
||||
navigator.mediaDevices.getUserMedia({
|
||||
@ -505,7 +574,13 @@
|
||||
method: 'POST',}
|
||||
);
|
||||
if (response.ok) {
|
||||
// this.thisItem = await response.json();
|
||||
|
||||
this.thisItem = await response.json();
|
||||
console.log(this.thisItem);
|
||||
if (this.thisItem.toOther === "Return" && this.thisItem.lastUser == this.currentUserId) {
|
||||
this.selectedAction = "receive";
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
@ -548,7 +548,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
public async Task<IActionResult> ItemMovementList()
|
||||
{
|
||||
|
||||
var itemMovementList = await _centralDbContext.ItemMovements.ToListAsync();
|
||||
var itemMovementList = await _centralDbContext.ItemMovements.Include(i => i.NextUser).ToListAsync();
|
||||
//var itemList = await _centralDbContext.Items.ToListAsync();
|
||||
|
||||
int itemrow = 0;
|
||||
@ -556,9 +556,12 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
{
|
||||
id = itemrow++,
|
||||
item, // Includes all properties of the original item
|
||||
QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.ItemId}" // Generate QR String
|
||||
QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.ItemId}", // Generate QR String
|
||||
userName = item.NextUser?.FullName
|
||||
}).ToList();
|
||||
Console.WriteLine(Json(itemMovementList));
|
||||
//Console.WriteLine(Json(itemMovementList));
|
||||
|
||||
|
||||
//return Json(itemMovementList);
|
||||
return Json(itemMovementListWithQR);
|
||||
}
|
||||
@ -574,13 +577,13 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
|
||||
try
|
||||
{
|
||||
if (itemmovement.ToUser == null)
|
||||
{
|
||||
throw new Exception("itemmovement.ToUser is null");
|
||||
}
|
||||
//if (itemmovement.ToUser == null)
|
||||
//{
|
||||
// throw new Exception("itemmovement.ToUser is null");
|
||||
//}
|
||||
|
||||
//var inventoryMaster = await _centralDbContext.InventoryMasters.Include("User").FirstOrDefaultAsync(i => i.UserId == itemmovement.ToUser) ?? new InventoryMasterModel { UserId = itemmovement.ToUser };
|
||||
var inventoryMaster = await _centralDbContext.InventoryMasters.FirstOrDefaultAsync(i => i.UserId == itemmovement.ToUser);
|
||||
var inventoryMaster = await _centralDbContext.InventoryMasters.Include("User").FirstOrDefaultAsync(i => i.UserId == itemmovement.ToUser);
|
||||
if (inventoryMaster != null)
|
||||
{
|
||||
itemmovement.ToStore = inventoryMaster.StoreId;
|
||||
@ -633,17 +636,41 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
updateItem.ItemStatus = 8;
|
||||
}
|
||||
|
||||
Console.WriteLine("updateItem.MovementId" + updateItem.MovementId);
|
||||
Console.WriteLine("itemmovement.Id" + itemmovement.Id);
|
||||
//Console.WriteLine("updateItem.MovementId" + updateItem.MovementId);
|
||||
//Console.WriteLine("itemmovement.Id" + itemmovement.Id);
|
||||
|
||||
updateItem.MovementId = itemmovement.Id;
|
||||
_centralDbContext.Items.Update(updateItem);
|
||||
|
||||
}
|
||||
|
||||
await _centralDbContext.SaveChangesAsync(); // save changes for table item - movementid
|
||||
|
||||
return Json(itemmovement);
|
||||
|
||||
}
|
||||
return Json(new
|
||||
{
|
||||
itemmovement.Id,
|
||||
itemmovement.ItemId,
|
||||
itemmovement.ToStation,
|
||||
itemmovement.ToStore,
|
||||
itemmovement.ToUser,
|
||||
itemmovement.ToOther,
|
||||
itemmovement.sendDate,
|
||||
itemmovement.Action,
|
||||
itemmovement.Quantity,
|
||||
itemmovement.Remark,
|
||||
itemmovement.ConsignmentNote,
|
||||
itemmovement.Date,
|
||||
itemmovement.LastUser,
|
||||
itemmovement.LastStore,
|
||||
itemmovement.LastStation,
|
||||
itemmovement.LatestStatus,
|
||||
itemmovement.receiveDate,
|
||||
itemmovement.MovementComplete
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
//return Json(itemmovement);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -652,6 +679,45 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
|
||||
}
|
||||
|
||||
[HttpPost("UpdateItemMovementMaster")]
|
||||
public async Task<IActionResult> UpdateItemMovementMaster([FromBody] ItemMovementModel receiveMovement)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
var updatedList = await _centralDbContext.ItemMovements.FindAsync(receiveMovement.Id);
|
||||
|
||||
if (updatedList == null)
|
||||
{
|
||||
return NotFound("Item movement record not found.");
|
||||
}
|
||||
|
||||
updatedList.LatestStatus = "Delivered";
|
||||
updatedList.receiveDate = receiveMovement.receiveDate;
|
||||
updatedList.MovementComplete = true;
|
||||
|
||||
_centralDbContext.ItemMovements.Update(updatedList);
|
||||
await _centralDbContext.SaveChangesAsync();
|
||||
|
||||
//var receiveItems = await _centralDbContext.Items.FindAsync(receiveMovement.ItemId);
|
||||
|
||||
//if (receiveItems != null)
|
||||
//{
|
||||
// receiveItems.ItemStatus = 3;
|
||||
// _centralDbContext.Items.Update(receiveItems);
|
||||
|
||||
// await _centralDbContext.SaveChangesAsync(); // Simpan perubahan
|
||||
//}
|
||||
|
||||
return Json(updatedList);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion ItemMovement
|
||||
|
||||
#region ItemMovementUser
|
||||
@ -835,13 +901,13 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
public async Task<IActionResult> ItemRequestList()
|
||||
{
|
||||
|
||||
var itemRequestList = await _centralDbContext.Requests.Include(i => i.Product).ToListAsync();
|
||||
var itemRequestList = await _centralDbContext.Requests.Include(i => i.Product).Include(i => i.User).ToListAsync();
|
||||
return Json(itemRequestList.Select(i => new
|
||||
{
|
||||
i.requestId,
|
||||
productName = i.Product?.ProductName,
|
||||
i.ProductId,
|
||||
i.UserId,
|
||||
userName = i.User?.FullName,
|
||||
i.status,
|
||||
i.StationId,
|
||||
i.RequestQuantity,
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
Loading…
Reference in New Issue
Block a user