fix merged
This commit is contained in:
commit
20c01825f9
@ -223,14 +223,15 @@
|
||||
"title": "Request ID",
|
||||
"data": "requestId",
|
||||
},
|
||||
{
|
||||
"title": "Product Name",
|
||||
"data": "productName",
|
||||
},
|
||||
{
|
||||
"title": "User ID",
|
||||
"data": "userId",
|
||||
},
|
||||
{
|
||||
"title": "Product ID",
|
||||
"data": "productId",
|
||||
},
|
||||
|
||||
{
|
||||
"title": "Product Category",
|
||||
"data": "productCategory",
|
||||
@ -344,8 +345,8 @@
|
||||
"data": "requestId",
|
||||
},
|
||||
{
|
||||
"title": "Product ID",
|
||||
"data": "productId",
|
||||
"title": "Product Name",
|
||||
"data": "productName",
|
||||
},
|
||||
{
|
||||
"title": "Product Category",
|
||||
|
||||
@ -312,7 +312,7 @@
|
||||
},
|
||||
{
|
||||
"title": "Product Id",
|
||||
"data": "productId",
|
||||
"data": "productName",
|
||||
},
|
||||
{
|
||||
"title": "Product Category",
|
||||
@ -400,7 +400,7 @@
|
||||
},
|
||||
{
|
||||
"title": "Product Id",
|
||||
"data": "productId",
|
||||
"data": "productName",
|
||||
},
|
||||
{
|
||||
"title": "Product Category",
|
||||
|
||||
@ -561,102 +561,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
Console.WriteLine(Json(itemMovementList));
|
||||
//return Json(itemMovementList);
|
||||
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")]
|
||||
@ -948,9 +852,24 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
public async Task<IActionResult> ItemRequestListEachUser(int userId)
|
||||
{
|
||||
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}")]
|
||||
@ -975,8 +894,23 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
public async Task<IActionResult> ItemRequestList()
|
||||
{
|
||||
|
||||
var itemRequestList = await _centralDbContext.Requests.ToListAsync();
|
||||
return Json(itemRequestList);
|
||||
var itemRequestList = await _centralDbContext.Requests.Include(i => i.Product).ToListAsync();
|
||||
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,
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
@ -1237,7 +1171,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
|
||||
// 2. Cari item movement yang ada ItemId & MovementComplete = false
|
||||
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
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 MiB |
Loading…
Reference in New Issue
Block a user