@@ -375,7 +376,15 @@
qrCodeResult: null,
debounceTimeout: null,
error: "",
- selectedConstraints: { facingMode: "environment" },
+ selectedConstraints: {
+ video: {
+ facingMode: "environment", // Kamera belakang
+ width: { ideal: 1920 }, // Resolusi tinggi
+ height: { ideal: 1080 },
+ focusMode: "continuous", // Auto-focus
+ zoom: 2.0
+ }
+ },
trackFunctionSelected: { text: 'outline', value: null },
barcodeFormats: {
qr_code: true, // Hanya mendukung QR Code
@@ -410,8 +419,8 @@
this.consignmentNote = null;
}
},
- async updateItemMovement() {
+ async updateStationItemMovement() {
const requiredFields = ['selectedStation'];
for (let field of requiredFields) {
@@ -421,6 +430,52 @@
}
}
+ try {
+ const now = new Date();
+ const formData = {
+ ItemId: this.thisItem.itemID,
+ ToStation: this.thisItem.currentStationId,
+ ToStore: this.thisItem.currentStoreId,
+ ToUser: this.currentUserId,
+ ToOther: "Delivered",
+ SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
+ Action: "Assign",
+ Quantity: this.thisItem.quantity,
+ Remark: this.remark,
+ ConsignmentNote: this.consignmentNote,
+ Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
+ LastUser: this.currentUserId,
+ LastStore: this.thisItem.currentStoreId,
+ LastStation: this.selectedStation,
+ LatestStatus: "Delivered",
+ ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
+ MovementComplete: true,
+ };
+
+ const response = await fetch('/InvMainAPI/StationItemMovementUser', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(formData)
+ });
+
+ if (response.ok) {
+ alert('Success! Item assign to the Station.');
+ $('#stationMessage').modal('hide');
+ this.displayStatus = "return";
+ this.thisItem = await response.json();
+ } else {
+ throw new Error('Failed to submit form.');
+ }
+ } catch (error) {
+ console.error('Error:', error);
+ alert('Inventory PSTW Error: An error occurred.');
+ }
+ },
+
+ async updateItemMovement() {
+
if (this.receiveReturn == null) {
if (!confirm("Are you sure you already received this item?")) {
return false;
@@ -430,8 +485,7 @@
try {
const now = new Date();
const formData = {
- Id: this.thisItem.movementId,
- LastStation: this.selectedStation,
+ Id : this.thisItem.id,
LatestStatus: "Delivered",
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
MovementComplete: true
@@ -463,6 +517,7 @@
alert('Inventory PSTW Error: An error occurred.');
}
},
+
async returnItemMovement() {
const requiredFields = ['remark', 'consignmentNote'];
@@ -534,7 +589,7 @@
if (this.thisItem.movementId != null && this.thisItem.toOther === "On Delivery" && this.thisItem.latestStatus == null && this.thisItem.currentUserId == this.currentUserId && this.thisItem.movementComplete == 0) {
this.displayStatus = "arrived";
- } else if (this.thisItem.movementId != null && this.thisItem.toOther === "On Delivery" && this.thisItem.latestStatus != null && this.thisItem.currentUserId == this.currentUserId && this.thisItem.latestStatus != "Ready To Deploy") {
+ } else if (this.thisItem.movementId != null && this.thisItem.latestStatus != null && this.thisItem.currentUserId == this.currentUserId && this.thisItem.latestStatus != "Ready To Deploy") {
this.displayStatus = "return";
} else if (this.thisItem.movementId != null && this.thisItem.toOther === "Return" && this.thisItem.latestStatus == null && this.thisItem.toUser == this.currentUserId) {
this.displayStatus = "requestAgain";
@@ -625,28 +680,38 @@
}
this.error = message;
},
-
//Setting Camera
async onCameraReady() {
- try {
- const devices = await navigator.mediaDevices.enumerateDevices();
- this.videoInputDevices = devices.filter(device => device.kind === 'videoinput');
-
- if (this.videoInputDevices.length > 0) {
- // Keep the selected camera if already chosen
- if (!this.selectedCameraId) {
- this.selectedCameraId = this.videoInputDevices[0].deviceId;
- }
-
- this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } };
- } else {
- this.error = "No camera detected.";
- }
- } catch (err) {
- this.error = "Error accessing camera: " + err.message;
- }
+ this.enableAutoFocus();
},
+ async enableAutoFocus() {
+ const devices = await navigator.mediaDevices.enumerateDevices();
+ this.videoInputDevices = devices.filter(device => device.kind === 'videoinput');
+
+ if (this.videoInputDevices.length > 0) {
+ // Keep the selected camera if already chosen
+ if (!this.selectedCameraId) {
+ this.selectedCameraId = this.videoInputDevices[0].deviceId;
+ }
+
+ this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } };
+ } else {
+ this.error = "No camera detected.";
+ }
+
+
+ const stream = await navigator.mediaDevices.getUserMedia({ video: true });
+ const track = stream.getVideoTracks()[0];
+ const capabilities = track.getCapabilities();
+
+ if(capabilities.focusMode) {
+ await track.applyConstraints({ focusMode: "continuous" }); // Auto-focus
+ }
+
+ },
+
+
//Update Camera Category
updateCamera() {
this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } };
@@ -679,6 +744,22 @@
closeModal() {
$('#returnModal').modal('hide'); // Manually hide the modal
},
+
+ ReturnMessage() {
+ $("#returnMessage").modal("show");
+ },
+
+ closeMessageModal() {
+ $('#returnMessage').modal('hide'); // Manually hide the modal
+ },
+
+ StationMessage() {
+ $("#stationMessage").modal("show");
+ },
+
+ closeStationMessageModal() {
+ $('#stationMessage').modal('hide'); // Manually hide the modal
+ },
},
});
app.component("qrcode-stream", VueQrcodeReader.QrcodeStream);
diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs
index 9fcd4ae..acccd7e 100644
--- a/Controllers/API/Inventory/InvMainAPI.cs
+++ b/Controllers/API/Inventory/InvMainAPI.cs
@@ -496,6 +496,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
}
var singleItem = new
{
+ item.Movement?.Id,
item.ItemID,
item.MovementId,
item.UniqueID,
@@ -853,20 +854,24 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{
if (!string.IsNullOrEmpty(request.Document))
{
+ var findUniqueCode = _centralDbContext.Products.FirstOrDefault(r => r.ProductId == request.ProductId);
+ var findUniqueUser = _centralDbContext.Users.FirstOrDefault(r => r.Id == request.UserId);
+
var bytes = Convert.FromBase64String(request.Document);
string filePath = "";
- string uniqueName = $"{request.ProductId}_{Guid.NewGuid()}";
+ var uniqueAbjad = new string(Enumerable.Range(0, 8).Select(_ => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[new Random().Next(36)]).ToArray());
+
if (IsImage(bytes))
{
- filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", uniqueName + request.UserId + "_Request.jpg");
- request.Document = "/media/inventory/request/" + uniqueName + request.UserId + "_Request.jpg";
+ filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "(" + uniqueAbjad + ") Request.jpg");
+ request.Document = "/media/inventory/request/" + findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "(" + uniqueAbjad + ") Request.jpg";
}
else if (IsPdf(bytes))
{
- filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", uniqueName + request.UserId + "_Request.pdf");
- request.Document = "/media/inventory/request/" + uniqueName + request.UserId + "_Request.pdf";
+ filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "_Request.pdf");
+ request.Document = "/media/inventory/request/" + findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "(" + uniqueAbjad + ") Request.pdf";
}
else
{
@@ -917,16 +922,17 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
public async Task ItemRequestListEachUser(int userId)
{
var requests = await _centralDbContext.Requests
- .Include(i => i.Product).Where(r => r.UserId == userId).ToListAsync();
+ .Include(i => i.Product).Include(i => i.Station).Where(r => r.UserId == userId).ToListAsync();
return Json(requests.Select(i => new
{
i.requestId,
- productName = i.Product?.ProductName,
i.ProductId,
+ productName = i.Product?.ProductName,
i.UserId,
i.status,
i.StationId,
+ stationName = i.Station?.StationName,
i.RequestQuantity,
i.requestDate,
i.ProductCategory,
@@ -1195,7 +1201,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return NotFound("Item movement record not found.");
}
- updatedList.LastStation = receiveMovement.LastStation;
updatedList.LatestStatus = receiveMovement.LatestStatus;
updatedList.receiveDate = receiveMovement.receiveDate;
updatedList.MovementComplete = receiveMovement.MovementComplete;
@@ -1308,6 +1313,95 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return BadRequest(ex.Message);
}
}
+
+ [HttpPost("StationItemMovementUser")]
+ public async Task StationItemMovementUser([FromBody] ItemMovementModel stationMovement)
+ {
+ if (!ModelState.IsValid)
+ {
+ return BadRequest(ModelState);
+ }
+
+ try
+ {
+ if (!string.IsNullOrEmpty(stationMovement.ConsignmentNote))
+ {
+ var bytes = Convert.FromBase64String(stationMovement.ConsignmentNote);
+ string filePath = "";
+
+ string uniqueName = $"{stationMovement.Id}_{Guid.NewGuid()}";
+
+ if (IsImage(bytes))
+ {
+ filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", uniqueName + stationMovement.ItemId + "_Request.jpg");
+ stationMovement.ConsignmentNote = "/media/inventory/request/" + uniqueName + stationMovement.ItemId + "_Request.jpg";
+ }
+ else if (IsPdf(bytes))
+ {
+ filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", uniqueName + stationMovement.ItemId + "_Request.pdf");
+ stationMovement.ConsignmentNote = "/media/inventory/request/" + uniqueName + stationMovement.ItemId + "_Request.pdf";
+ }
+ else
+ {
+ return BadRequest("Unsupported file format.");
+ }
+
+ await System.IO.File.WriteAllBytesAsync(filePath, bytes);
+ }
+ // 1. Simpan returnMovement dalam database
+ _centralDbContext.ItemMovements.Add(stationMovement);
+ await _centralDbContext.SaveChangesAsync();
+
+ // 2. Cari item movement yang ada ItemId & MovementComplete = false
+ var updateItemIdMovement = await _centralDbContext.ItemMovements
+ .FirstOrDefaultAsync(m => m.Id == stationMovement.Id);
+
+
+ // 3. Jika wujud, update MovementId
+ if (updateItemIdMovement != null)
+ {
+ var returnItems = await _centralDbContext.Items.FindAsync(updateItemIdMovement.ItemId);
+
+ if (returnItems != null)
+ {
+ returnItems.MovementId = updateItemIdMovement.Id;
+ returnItems.ItemStatus = 3;
+ _centralDbContext.Items.Update(returnItems);
+
+ await _centralDbContext.SaveChangesAsync(); // Simpan perubahan
+ }
+ }
+
+ return Json(new
+ {
+ updateItemIdMovement.Id,
+ updateItemIdMovement.ItemId,
+ updateItemIdMovement.ToStation,
+ updateItemIdMovement.ToStore,
+ updateItemIdMovement.ToUser,
+ updateItemIdMovement.ToOther,
+ updateItemIdMovement.sendDate,
+ updateItemIdMovement.Action,
+ updateItemIdMovement.Quantity,
+ updateItemIdMovement.Remark,
+ updateItemIdMovement.ConsignmentNote,
+ updateItemIdMovement.Date,
+ updateItemIdMovement.LastUser,
+ updateItemIdMovement.LastStore,
+ updateItemIdMovement.LastStation,
+ updateItemIdMovement.LatestStatus,
+ updateItemIdMovement.receiveDate,
+ updateItemIdMovement.MovementComplete
+ });
+
+
+ }
+ catch (Exception ex)
+ {
+ return BadRequest(ex.Message);
+ }
+ }
+
#endregion
}
}
diff --git a/wwwroot/Media/Inventory/request/0_2cdb34d3-2ecf-4cae-807c-ae38d76ac2a61_Request.jpg b/wwwroot/Media/Inventory/request/0_2cdb34d3-2ecf-4cae-807c-ae38d76ac2a61_Request.jpg
new file mode 100644
index 0000000..fa7280b
Binary files /dev/null and b/wwwroot/Media/Inventory/request/0_2cdb34d3-2ecf-4cae-807c-ae38d76ac2a61_Request.jpg differ
diff --git a/wwwroot/Media/Inventory/request/0_82ea8627-c256-449d-9b3a-c4edf10e5a681_Request.jpg b/wwwroot/Media/Inventory/request/0_82ea8627-c256-449d-9b3a-c4edf10e5a681_Request.jpg
new file mode 100644
index 0000000..fa7280b
Binary files /dev/null and b/wwwroot/Media/Inventory/request/0_82ea8627-c256-449d-9b3a-c4edf10e5a681_Request.jpg differ
diff --git a/wwwroot/Media/Inventory/request/0_b04540e4-4d83-4abe-8a7e-828869c07acb1_Request.jpg b/wwwroot/Media/Inventory/request/0_b04540e4-4d83-4abe-8a7e-828869c07acb1_Request.jpg
new file mode 100644
index 0000000..fa7280b
Binary files /dev/null and b/wwwroot/Media/Inventory/request/0_b04540e4-4d83-4abe-8a7e-828869c07acb1_Request.jpg differ
diff --git a/wwwroot/Media/Inventory/request/14 Latitude 7410_Request.jpg b/wwwroot/Media/Inventory/request/14 Latitude 7410_Request.jpg
new file mode 100644
index 0000000..bca4548
Binary files /dev/null and b/wwwroot/Media/Inventory/request/14 Latitude 7410_Request.jpg differ
diff --git a/wwwroot/Media/Inventory/request/hilmi.rezuan Latitude 7410(KY7ES9KZ) Request.jpg b/wwwroot/Media/Inventory/request/hilmi.rezuan Latitude 7410(KY7ES9KZ) Request.jpg
new file mode 100644
index 0000000..bc663ee
Binary files /dev/null and b/wwwroot/Media/Inventory/request/hilmi.rezuan Latitude 7410(KY7ES9KZ) Request.jpg differ