update Qr

This commit is contained in:
ArifHilmi 2025-02-24 16:32:17 +08:00
parent 531106d90d
commit 646136aade
6 changed files with 207 additions and 796 deletions

View File

@ -15,7 +15,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers
{
return View();
}
public ActionResult Qr()
public ActionResult QrUser()
{
return View();
}

View File

@ -14,6 +14,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public int? ToUser { get; set; }
[Comment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery")]
public string? ToOther { get; set; }
public DateTime sendDate { get; set; }
[Comment("Register, StockIn, Stock Out")]
public string? Action { get; set; }
public int? Quantity { get; set; }
@ -25,6 +26,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public int? LastStation{ get; set; }
[Comment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery")]
public string? LatestStatus { get; set; }
public DateTime receiveDate { get; set; }
public bool MovementComplete { get; set; } = false;
//public virtual ItemModel? Item { get; set; }
//[ForeignKey("ToStore")]

View File

@ -323,13 +323,17 @@
},
{
"title": "Delete",
"data": "requestId",
"render": function (data) {
var deleteButton = `<button type="button" class="btn btn-danger delete-btn" data-id="${data}">Delete</button>`;
return deleteButton;
},
"data": "requestId",
"render": function (data, type, row) {
if (row.status === "Approved" || row.status === "Rejected") {
return `<button type="button" class="btn btn-danger delete-btn" data-id="${data}" disabled>Delete</button>`;
} else {
return `<button type="button" class="btn btn-danger delete-btn" data-id="${data}">Delete</button>`;
}
},
"className": "align-middle",
}
],
responsive: true,
})

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
<div class="col-6 col-md-6 col-lg-3">
<div class="card card-hover">
<a asp-area="Inventory" asp-controller="ItemMovement" asp-action="Qr">
<a asp-area="Inventory" asp-controller="ItemMovement" asp-action="QrUser">
<div class="box bg-success text-center">
<h1 class="font-light text-white">
<i class="mdi mdi-checkbox-multiple-blank-circle"></i>

View File

@ -474,6 +474,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
.Include("CreatedBy")
.Include("Department")
.Include("Product")
.Include("Movement")
.Include(i => i.Movement)
.ThenInclude(m => m!.FromStore)
.Include(i => i.Movement)
@ -486,6 +487,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
var singleItem = new
{
item.ItemID,
item.MovementId,
item.UniqueID,
item.CompanyId,
item.DepartmentId,
@ -510,8 +512,11 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.Product!.ProductShortName,
item.Product!.ImageProduct,
CurrentUser = item.Movement?.FromUser?.UserName,
CurrentUserId = item.Movement?.FromUser?.Id,
CurrentStore = item.Movement?.FromStore?.StoreName,
CurrentStation = item.Movement?.FromStation?.StationName,
item.Movement?.ToOther,
item.Movement?.LatestStatus,
QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
};
return Json(singleItem);
@ -755,8 +760,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
}
}
[HttpGet("ItemRequestListEachUser/{userId}")]
public async Task<IActionResult> ItemRequestListEachUser(int userId)
{
@ -766,7 +769,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return Ok(requests);
}
[HttpDelete("DeleteRequest/{requestId}")]
public async Task<IActionResult> DeleteRequest(int requestId)
{
@ -989,5 +991,86 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
#endregion AllUser
#region ScannerUser
[HttpPost("UpdateItemMovementUser")]
public async Task<IActionResult> UpdateItemMovementUser([FromBody] ItemMovementModel receiveMovement)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
try
{
var updatedList = await _centralDbContext.ItemMovements.FindAsync(receiveMovement.Id);
if (updatedList == null)
{
return NotFound("Item movement record not found.");
}
updatedList.LastStation = receiveMovement.LastStation;
updatedList.LatestStatus = receiveMovement.LatestStatus;
updatedList.receiveDate = receiveMovement.receiveDate;
updatedList.MovementComplete = receiveMovement.MovementComplete;
_centralDbContext.ItemMovements.Update(updatedList);
await _centralDbContext.SaveChangesAsync();
return Json(updatedList);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost("ReturnItemMovementUser")]
public async Task<IActionResult> ReturnItemMovementUser([FromBody] ItemMovementModel returnMovement)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
try
{
var updatedList = await _centralDbContext.ItemMovements
.Where(r => r.Id == returnMovement.Id)
.FirstAsync();
updatedList.ItemId = updatedList.ItemId;
updatedList.ToStation = updatedList.ToStation;
updatedList.ToStore = updatedList.ToStore;
updatedList.ToUser = updatedList.ToUser;
updatedList.ToOther = updatedList.ToOther;
updatedList.sendDate = updatedList.sendDate;
updatedList.ToStation = updatedList.ToStation;
updatedList.Action = updatedList.Action;
updatedList.Quantity = updatedList.Quantity;
updatedList.Remark = updatedList.Remark;
updatedList.ConsignmentNote = updatedList.ConsignmentNote;
updatedList.Date = updatedList.Date;
updatedList.LastUser = updatedList.LastUser;
updatedList.LastStore = updatedList.ToStore;
updatedList.LastStation = returnMovement.LastStation;
updatedList.LatestStatus = returnMovement.LatestStatus;
updatedList.receiveDate = returnMovement.receiveDate;
updatedList.MovementComplete = returnMovement.MovementComplete;
await _centralDbContext.SaveChangesAsync();
return Json(updatedList);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
#endregion
}
}