request & Qr
This commit is contained in:
parent
31254a6460
commit
8cf3fd9b14
@ -224,8 +224,8 @@
|
|||||||
"data": "requestId",
|
"data": "requestId",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Product ID",
|
"title": "Product Name",
|
||||||
"data": "productId",
|
"data": "productName",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Product Category",
|
"title": "Product Category",
|
||||||
@ -340,8 +340,8 @@
|
|||||||
"data": "requestId",
|
"data": "requestId",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Product ID",
|
"title": "Product Name",
|
||||||
"data": "productId",
|
"data": "productName",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Product Category",
|
"title": "Product Category",
|
||||||
|
|||||||
@ -374,7 +374,7 @@
|
|||||||
this.startScanner();
|
this.startScanner();
|
||||||
this.fetchUsers();
|
this.fetchUsers();
|
||||||
this.fetchStores();
|
this.fetchStores();
|
||||||
this.fetchItem('ARA00500008'); // for testing only. clear this
|
// this.fetchItem('ARA00500008'); for testing only. clear this
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
filteredDepartments() {
|
filteredDepartments() {
|
||||||
@ -451,7 +451,7 @@
|
|||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
// window.location.href = '/Inventory/InventoryMaster/ItemMovement';
|
window.location.href = '/Inventory/InventoryMaster/ItemMovement';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Failed to submit form.');
|
throw new Error('Failed to submit form.');
|
||||||
|
|||||||
@ -312,7 +312,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Product Id",
|
"title": "Product Id",
|
||||||
"data": "productId",
|
"data": "productName",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Product Category",
|
"title": "Product Category",
|
||||||
@ -400,7 +400,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Product Id",
|
"title": "Product Id",
|
||||||
"data": "productId",
|
"data": "productName",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Product Category",
|
"title": "Product Category",
|
||||||
|
|||||||
@ -561,102 +561,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
Console.WriteLine(Json(itemMovementList));
|
Console.WriteLine(Json(itemMovementList));
|
||||||
//return Json(itemMovementList);
|
//return Json(itemMovementList);
|
||||||
return Json(itemMovementListWithQR);
|
return Json(itemMovementListWithQR);
|
||||||
|
|
||||||
|
|
||||||
//try
|
|
||||||
//{
|
|
||||||
// var user = await _userManager.GetUserAsync(User);
|
|
||||||
// if (user == null)
|
|
||||||
// {
|
|
||||||
// return BadRequest("User not found");
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// user.departmentId = user.departmentId != null ? user.departmentId : 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var userRole = await _userManager.GetRolesAsync(user);
|
|
||||||
// var isAdmin = userRole.Contains("SystemAdmin") || userRole.Contains("SuperAdmin") || userRole.Contains("Finance");
|
|
||||||
// List<ItemModel> itemList = new List<ItemModel>();
|
|
||||||
// // Get the item list
|
|
||||||
// if (isAdmin)
|
|
||||||
// {
|
|
||||||
// itemList = await _centralDbContext.Items
|
|
||||||
// .AsNoTracking()
|
|
||||||
// .Include("CreatedBy")
|
|
||||||
// .Include("Department")
|
|
||||||
// .Include("Product")
|
|
||||||
// .Include(i => i.Movement)
|
|
||||||
// .ThenInclude(m => m!.FromStore)
|
|
||||||
// .Include(i => i.Movement)
|
|
||||||
// .ThenInclude(m => m!.FromStation)
|
|
||||||
// .Include(i => i.Movement)
|
|
||||||
// .ThenInclude(m => m!.FromUser)
|
|
||||||
// .ToListAsync();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// itemList = await _centralDbContext.Items
|
|
||||||
// .AsNoTracking()
|
|
||||||
// .Include("CreatedBy")
|
|
||||||
// .Include("Department")
|
|
||||||
// .Include("Product")
|
|
||||||
// .Include(i => i.Movement)
|
|
||||||
// .ThenInclude(m => m!.FromStore)
|
|
||||||
// .Include(i => i.Movement)
|
|
||||||
// .ThenInclude(m => m!.FromStation)
|
|
||||||
// .Include(i => i.Movement)
|
|
||||||
// .ThenInclude(m => m!.FromUser)
|
|
||||||
// .Where(i => i.DepartmentId == user.departmentId)
|
|
||||||
// .ToListAsync();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Get the departments list (DepartmentId references Departments)
|
|
||||||
// var departments = await _centralDbContext.Departments.ToListAsync();
|
|
||||||
|
|
||||||
// // Now join items with users and departments manually
|
|
||||||
// var itemListWithDetails = itemList.Select(item => new
|
|
||||||
// {
|
|
||||||
// item.ItemID,
|
|
||||||
// item.UniqueID,
|
|
||||||
// item.CompanyId,
|
|
||||||
// item.DepartmentId,
|
|
||||||
// item.ProductId,
|
|
||||||
// item.SerialNumber,
|
|
||||||
// item.Quantity,
|
|
||||||
// item.Supplier,
|
|
||||||
// PurchaseDate = item.PurchaseDate.ToString("dd/MM/yyyy"),
|
|
||||||
// item.PONo,
|
|
||||||
// item.Currency,
|
|
||||||
// item.DefaultPrice,
|
|
||||||
// item.CurrencyRate,
|
|
||||||
// item.ConvertPrice,
|
|
||||||
// item.DODate,
|
|
||||||
// item.Warranty,
|
|
||||||
// item.PartNumber,
|
|
||||||
// EndWDate = item.EndWDate.ToString("dd/MM/yyyy"),
|
|
||||||
// InvoiceDate = item.InvoiceDate?.ToString("dd/MM/yyyy"),
|
|
||||||
// item.Department?.DepartmentName,
|
|
||||||
// CreatedBy = item.CreatedBy!.UserName,
|
|
||||||
// item.Product!.ProductName,
|
|
||||||
// item.Product!.ProductShortName,
|
|
||||||
// item.Product!.Category,
|
|
||||||
// //CurrentUser = item.Movement?.FromUser?.UserName,
|
|
||||||
// CurrentUser = item.Movement?.FromUser?.UserName,
|
|
||||||
// CurrentStore = item.Movement?.FromStore?.StoreName,
|
|
||||||
// CurrentStation = item.Movement?.FromStation?.StationName,
|
|
||||||
|
|
||||||
// QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
|
|
||||||
// }).ToList();
|
|
||||||
|
|
||||||
// return Json(itemListWithDetails);
|
|
||||||
//}
|
|
||||||
//catch (Exception ex)
|
|
||||||
//{
|
|
||||||
// return BadRequest(ex.Message);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("AddItemMovement")]
|
[HttpPost("AddItemMovement")]
|
||||||
@ -886,9 +790,24 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
public async Task<IActionResult> ItemRequestListEachUser(int userId)
|
public async Task<IActionResult> ItemRequestListEachUser(int userId)
|
||||||
{
|
{
|
||||||
var requests = await _centralDbContext.Requests
|
var requests = await _centralDbContext.Requests
|
||||||
.Where(r => r.UserId == userId).ToListAsync();
|
.Include(i => i.Product).Where(r => r.UserId == userId).ToListAsync();
|
||||||
|
|
||||||
return Ok(requests);
|
return Json(requests.Select(i => new
|
||||||
|
{
|
||||||
|
i.requestId,
|
||||||
|
productName = i.Product?.ProductName,
|
||||||
|
i.ProductId,
|
||||||
|
i.UserId,
|
||||||
|
i.status,
|
||||||
|
i.StationId,
|
||||||
|
i.RequestQuantity,
|
||||||
|
i.requestDate,
|
||||||
|
i.ProductCategory,
|
||||||
|
i.Document,
|
||||||
|
i.approvalDate,
|
||||||
|
i.remarkMasterInv,
|
||||||
|
i.remarkUser,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("DeleteRequest/{requestId}")]
|
[HttpDelete("DeleteRequest/{requestId}")]
|
||||||
@ -913,8 +832,23 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
public async Task<IActionResult> ItemRequestList()
|
public async Task<IActionResult> ItemRequestList()
|
||||||
{
|
{
|
||||||
|
|
||||||
var itemRequestList = await _centralDbContext.Requests.ToListAsync();
|
var itemRequestList = await _centralDbContext.Requests.Include(i => i.Product).ToListAsync();
|
||||||
return Json(itemRequestList);
|
return Json(itemRequestList.Select(i => new
|
||||||
|
{
|
||||||
|
i.requestId,
|
||||||
|
productName = i.Product?.ProductName,
|
||||||
|
i.ProductId,
|
||||||
|
i.UserId,
|
||||||
|
i.status,
|
||||||
|
i.StationId,
|
||||||
|
i.RequestQuantity,
|
||||||
|
i.requestDate,
|
||||||
|
i.ProductCategory,
|
||||||
|
i.Document,
|
||||||
|
i.approvalDate,
|
||||||
|
i.remarkMasterInv,
|
||||||
|
i.remarkUser,
|
||||||
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1175,7 +1109,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
|
|
||||||
// 2. Cari item movement yang ada ItemId & MovementComplete = false
|
// 2. Cari item movement yang ada ItemId & MovementComplete = false
|
||||||
var updateItemIdMovement = await _centralDbContext.ItemMovements
|
var updateItemIdMovement = await _centralDbContext.ItemMovements
|
||||||
.FirstOrDefaultAsync(m => m.ItemId == returnMovement.ItemId && m.MovementComplete == false);
|
.FirstOrDefaultAsync(m => m.Id == returnMovement.Id && m.MovementComplete == false);
|
||||||
|
|
||||||
|
|
||||||
// 3. Jika wujud, update MovementId
|
// 3. Jika wujud, update MovementId
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 MiB |
Loading…
Reference in New Issue
Block a user