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(); return View();
} }
public ActionResult Qr() public ActionResult QrUser()
{ {
return View(); return View();
} }

View File

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

View File

@ -323,13 +323,17 @@
}, },
{ {
"title": "Delete", "title": "Delete",
"data": "requestId", "data": "requestId",
"render": function (data) { "render": function (data, type, row) {
var deleteButton = `<button type="button" class="btn btn-danger delete-btn" data-id="${data}">Delete</button>`; if (row.status === "Approved" || row.status === "Rejected") {
return deleteButton; 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", "className": "align-middle",
} }
], ],
responsive: true, 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="col-6 col-md-6 col-lg-3">
<div class="card card-hover"> <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"> <div class="box bg-success text-center">
<h1 class="font-light text-white"> <h1 class="font-light text-white">
<i class="mdi mdi-checkbox-multiple-blank-circle"></i> <i class="mdi mdi-checkbox-multiple-blank-circle"></i>

View File

@ -474,6 +474,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
.Include("CreatedBy") .Include("CreatedBy")
.Include("Department") .Include("Department")
.Include("Product") .Include("Product")
.Include("Movement")
.Include(i => i.Movement) .Include(i => i.Movement)
.ThenInclude(m => m!.FromStore) .ThenInclude(m => m!.FromStore)
.Include(i => i.Movement) .Include(i => i.Movement)
@ -486,6 +487,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
var singleItem = new var singleItem = new
{ {
item.ItemID, item.ItemID,
item.MovementId,
item.UniqueID, item.UniqueID,
item.CompanyId, item.CompanyId,
item.DepartmentId, item.DepartmentId,
@ -510,8 +512,11 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.Product!.ProductShortName, item.Product!.ProductShortName,
item.Product!.ImageProduct, item.Product!.ImageProduct,
CurrentUser = item.Movement?.FromUser?.UserName, CurrentUser = item.Movement?.FromUser?.UserName,
CurrentUserId = item.Movement?.FromUser?.Id,
CurrentStore = item.Movement?.FromStore?.StoreName, CurrentStore = item.Movement?.FromStore?.StoreName,
CurrentStation = item.Movement?.FromStation?.StationName, 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 QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
}; };
return Json(singleItem); return Json(singleItem);
@ -755,8 +760,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
} }
} }
[HttpGet("ItemRequestListEachUser/{userId}")] [HttpGet("ItemRequestListEachUser/{userId}")]
public async Task<IActionResult> ItemRequestListEachUser(int userId) public async Task<IActionResult> ItemRequestListEachUser(int userId)
{ {
@ -766,7 +769,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return Ok(requests); return Ok(requests);
} }
[HttpDelete("DeleteRequest/{requestId}")] [HttpDelete("DeleteRequest/{requestId}")]
public async Task<IActionResult> DeleteRequest(int requestId) public async Task<IActionResult> DeleteRequest(int requestId)
{ {
@ -989,5 +991,86 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
#endregion AllUser #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
} }
} }