This commit is contained in:
ameerulrasyid 2025-03-03 15:57:01 +08:00
commit 4afac02583
10 changed files with 373 additions and 158 deletions

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using PSTW_CentralSystem.Models;
namespace PSTW_CentralSystem.Areas.Inventory.Models namespace PSTW_CentralSystem.Areas.Inventory.Models
{ {
public class ProductModel public class ProductModel

View File

@ -11,7 +11,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public int ProductId { get; set; } public int ProductId { get; set; }
[ForeignKey("ProductId")] [ForeignKey("ProductId")]
public virtual ProductModel? Product { get; set; } public virtual ProductModel? Product { get; set; }
public int StationId { get; set; } public int? StationId { get; set; }
[ForeignKey("StationId")] [ForeignKey("StationId")]
public virtual StationModel? Station { get; set; } public virtual StationModel? Station { get; set; }
public int UserId { get; set; } public int UserId { get; set; }
@ -23,7 +23,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public string? status { get; set; } public string? status { get; set; }
public DateTime requestDate { get; set; } public DateTime requestDate { get; set; }
public DateTime? approvalDate { get; set; } public DateTime? approvalDate { get; set; }
public int RequestQuantity { get; set; } public int? RequestQuantity { get; set; }
public string? Document { get; set; } public string? Document { get; set; }
} }

View File

@ -78,7 +78,8 @@
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-4 col-form-label">Product</label> <label class="col-sm-4 col-form-label">Product</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select class="btn btn-primary form-select" v-model="productId" required> <div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-12" data-toggle="dropdown" aria-expanded="false" v-model="productId" required>
<option class="btn-light" value="" disabled selected>Select Product</option> <option class="btn-light" value="" disabled selected>Select Product</option>
<option class="btn-light" v-for="(item, index) in products" :key="index" :value="item.productId"> <option class="btn-light" v-for="(item, index) in products" :key="index" :value="item.productId">
{{ item.productName + ' (' + item.modelNo + ')' }} {{ item.productName + ' (' + item.modelNo + ')' }}
@ -86,17 +87,13 @@
</select> </select>
</div> </div>
</div> </div>
</div>
<!-- Category Dropdown --> <!-- Category Dropdown -->
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-4 col-form-label">Category:</label> <label class="col-sm-4 col-form-label">Category:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class=""> <input type="text" id="category" name="category" v-model="showProduct.category" class="form-control" readonly />
<select class="btn btn-primary form-select" v-model="productCategory" required>
<option class="btn-light" value="" selected disabled>Select Category</option>
<option class="btn-light" v-for="(item, index) in categories" :key="item" :value="item">{{ item ?? 'Select Category' }}</option>
</select>
</div>
</div> </div>
</div> </div>
@ -108,11 +105,25 @@
</div> </div>
</div> </div>
<!-- Station Dropdown --> @* Who will assign to *@
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-4 col-form-label">Item Assignment : </label>
<div class="col-sm-8">
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-12" v-model="assign"required>
<option class="btn-light" value="" selected disabled>Select Assignment Type</option>
<option class="btn-light" v-for="(item, index) in assigns" :key="item" :value="item">{{ item ?? 'Select Assignment Type' }}</option>
</select>
</div>
</div>
</div>
<!-- Station Dropdown -->
<div class="form-group row" v-if="assign === 'Station'">
<label class="col-sm-4 col-form-label">Station:</label> <label class="col-sm-4 col-form-label">Station:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select class="btn btn-primary form-select" v-model="stationId" required> <div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-12" data-toggle="dropdown" aria-expanded="false" v-model="stationId" required>
<option class="btn-light" value="" disabled selected>Select Station</option> <option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(item, index) in stations" :key="index" :value="item.stationId"> <option class="btn-light" v-for="(item, index) in stations" :key="index" :value="item.stationId">
{{ item.stationName }} {{ item.stationName }}
@ -120,6 +131,7 @@
</select> </select>
</div> </div>
</div> </div>
</div>
<!-- Remark Input (Wider) --> <!-- Remark Input (Wider) -->
<div class="form-group row d-flex align-items-center"> <div class="form-group row d-flex align-items-center">
@ -180,8 +192,8 @@
return { return {
requestId : null, requestId : null,
userId : null, userId : null,
stationId : null, stationId : "",
productId : null, productId : "",
remark: "", remark: "",
document: null, document: null,
quantity: 0, quantity: 0,
@ -189,14 +201,14 @@
requestDate : null, requestDate : null,
approvalDate : null, approvalDate : null,
productCategory: "", productCategory: "",
assign: "",
productName: null, productName: null,
productCategory: null,
stations: [], stations: [],
selectedProduct: "", selectedProduct: "",
selectedStation: "", selectedStation: "",
selectedCategory: "", selectedCategory: "",
categories: ["Asset", "Part", "Disposable"], assigns: ["Self-Assign", "Station"],
showRequestModal: false, showRequestModal: false,
loading: false, loading: false,
products: [], products: [],
@ -213,12 +225,14 @@
]); ]);
}, },
computed: { computed: {
showProduct() { showProduct() {
if (!this.selectedProduct) { if (!this.productId) {
return []; // No company selected, return empty list return []; // No company selected, return empty list
} }
const product = this.products.find(c => c.productId === this.selectedProduct); const product = this.products.find(c => c.productId === this.productId);
this.productCategory = product.category;
return product ? product : {}; return product ? product : {};
}, },
}, },
@ -238,7 +252,7 @@
}, },
async addRequest() { async addRequest() {
try { try {
const requiredFields = ['stationId', 'productId', 'quantity', 'productCategory']; const requiredFields = ['productId', 'quantity', 'assign'];
// Loop through required fields and check if any are null or empty // Loop through required fields and check if any are null or empty
for (let field of requiredFields) { for (let field of requiredFields) {
@ -248,6 +262,17 @@
} }
} }
if (this.assign === "Station"){
if (this.stationId == null) {
alert('Request Error', `Please fill in required fields : Station.`, 'warning');
return;
}
}
if (this.assign === "Self-Assign"){
this.stationId = null;
}
this.userId = this.currentUser.id; this.userId = this.currentUser.id;
this.status = "Requested"; this.status = "Requested";
@ -356,6 +381,13 @@
"title": "Remark", "title": "Remark",
"data": "remarkUser", "data": "remarkUser",
}, },
{
"title": "Station Deploy",
"data": "stationName",
"render": function (data, type, full, meta) {
return data ? data : "Self Assign";
}
},
{ {
"title": "Request Date", "title": "Request Date",
"data": "requestDate", "data": "requestDate",
@ -410,6 +442,13 @@
"title": "Request Quantity", "title": "Request Quantity",
"data": "requestQuantity", "data": "requestQuantity",
}, },
{
"title": "Station Deploy",
"data": "stationName",
"render": function (data, type, full, meta) {
return data ? data : "Self Assign";
}
},
{ {
"title": "Document / Picture", "title": "Document / Picture",
"data": "document", "data": "document",
@ -562,8 +601,8 @@
}, },
resetForm() { resetForm() {
this.stationId = null; this.stationId = "";
this.productId = null; this.productId = "";
this.remark = ""; this.remark = "";
this.document = null; this.document = null;
this.quantity = 0; this.quantity = 0;
@ -571,9 +610,9 @@
this.requestDate = null; this.requestDate = null;
this.approvalDate = null; this.approvalDate = null;
this.productCategory = ""; this.productCategory = "";
this.assign = "",
this.productName = null; this.productName = null;
this.productCategory = null;
this.selectedProduct = ""; this.selectedProduct = "";
this.selectedStation = ""; this.selectedStation = "";
this.selectedCategory = ""; this.selectedCategory = "";
@ -615,6 +654,7 @@
this.loading = false; this.loading = false;
} }
}, },
}, },
}); });
</script> </script>

View File

@ -53,11 +53,22 @@
</div> </div>
<!--RECEIVE OR RETURN INTERFACE --> <!--RECEIVE OR RETURN INTERFACE -->
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived'"> <div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived' && thisItem.currentStationId != null">
<h2>Item Receive Information :</h2> <h2>Item Receive Information :</h2>
<h3>Station Assign</h3>
</div> </div>
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'return'"> <div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived' && thisItem.currentStationId == null">
<h2>Item Receive Information :</h2>
<h3>Self Assign</h3>
</div>
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'return' && thisItem.currentStationId != null">
<h2>Item Return Information :</h2> <h2>Item Return Information :</h2>
<h3>Station</h3>
</div>
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'return' && thisItem.currentStationId == null">
<h2>Item Return Information :</h2>
<h3>Self Assign</h3>
</div> </div>
<div v-if="displayStatus === 'arrived' || displayStatus === 'return'" style="display: flex; justify-content: center; align-items: center;"> <div v-if="displayStatus === 'arrived' || displayStatus === 'return'" style="display: flex; justify-content: center; align-items: center;">
@ -102,7 +113,7 @@
<div class="col-12 mb-3"> <div class="col-12 mb-3">
<p class="h5 fw-bold"> <p class="h5 fw-bold">
<i class="fas fa-user-tie me-2 text-secondary"></i>PIC: <i class="fas fa-user-tie me-2 text-secondary"></i>PIC:
<span class="text-muted">Station PIC</span> <span class="text-muted">{{thisItem.currentStation || 'No Station Deploy (Self Assign)' }}</span>
</p> </p>
</div> </div>
@ -126,21 +137,13 @@
</div> </div>
</li> </li>
<!-- Store -->
<li class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">
<i class="mdi mdi-factory me-2 text-secondary"></i>Store:
</span>
<span class="text-muted">{{ thisItem.currentStore }}</span>
</li>
<!-- Station --> <!-- Station -->
<li class="list-group-item d-flex justify-content-between align-items-center"> <!-- <li class="list-group-item d-flex justify-content-between align-items-center"> -->
<span class="fw-bold"> <!-- <span class="fw-bold"> -->
<i class="fas fa-map-marker-alt me-2 text-secondary"></i>Station: <!-- <i class="fas fa-map-marker-alt me-2 text-secondary"></i>Station: -->
</span> <!-- </span> -->
<span class="text-muted">{{ thisItem.currentStation || 'N/A' }}</span> <!-- <span class="text-muted">{{ thisItem.currentStation || 'N/A' }}</span> -->
</li> <!-- </li> -->
</ul> </ul>
</div> </div>
</div> </div>
@ -166,21 +169,6 @@
</div> </div>
</li> </li>
<!-- Store -->
<li class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">
<i class="mdi mdi-factory me-2 text-secondary"></i>Store:
</span>
<span class="text-muted">{{ thisItem.toStoreName }}</span>
</li>
<!-- Station -->
<li class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">
<i class="fas fa-map-marker-alt me-2 text-secondary"></i>Station:
</span>
<span class="text-muted">{{ thisItem.toStationName || 'N/A' }}</span>
</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -200,32 +188,15 @@
<div class="tab-content" id="myTabContent"> <div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab"> <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<br><br> <br><br>
<h3 style="text-align: center; margin: 20px 0; padding: 20px;" class="register-heading" style="margin: auto">Station Deploy :</h3>
<div class="row register-form">
<div class="col-md-3"></div>
<div class="col-md-6">
<!-- Station Dropdown -->
<div class="form-group row">
<label class="col-sm-4 col-form-label">Deploy Station : </label>
<div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStation">
<option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(station, index) in stationList" :key="index" :value="station.stationId">{{ station.stationName}}</option>
</select>
</div>
</div>
</div>
@* Submit and Reset Buttons *@ @* Submit and Reset Buttons *@
<div class="form-group row"> <div class="form-group row">
<div class="col-sm-8 offset-sm-3"> <div class="col-sm-8 offset-sm-3">
<button type="button" v-on:click="receiveReturnMessage" class="btn btn-secondary m-1">Return Item</button> <button type="button" v-on:click="ReturnMessage" class="btn btn-secondary m-1">Return Item</button>
<button type="submit" class="btn btn-primary m-1">Receive Item</button> <button type="submit" class="btn btn-primary m-1">Receive Item</button>
</div> </div>
</div> </div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -235,7 +206,7 @@
</form> </form>
<!--RETURN INTERFACE --> <!--RETURN INTERFACE -->
<form v-on:submit.prevent="returnItemMovement" v-if="displayStatus === 'return'" data-aos="fade-right"> <form v-on:submit.prevent="" v-if="displayStatus === 'return'" data-aos="fade-right">
<div class=" register" data-aos="fade-right"> <div class=" register" data-aos="fade-right">
<div class="row" data-aos="fade-right"> <div class="row" data-aos="fade-right">
@ -244,35 +215,14 @@
<div class="tab-content" id="myTabContent"> <div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab"> <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<br><br> <br><br>
<h3 style="text-align: center; margin: 20px 0; padding: 20px;" class="register-heading" style="margin: auto">Station Deploy :</h3>
<div class="row register-form">
<div class="col-md-3"></div>
<div class="col-md-6">
<!-- Remark Input -->
<div class="form-group row">
<label class="col-sm-4 col-form-label">Remark : </label>
<div class="col-sm-8">
<input type="text" class="form-control col-md-10" v-model="remark" />
</div>
</div>
<!-- Consignment Note input -->
<div class="form-group row">
<label class="col-sm-4 col-form-label">Consignment Note : </label>
<div class="col-sm-8">
<input type="file" v-on:change="handleFileUpload" class="form-control-file" accept="image/png, image/jpeg, application/pdf" />
</div>
</div>
</div>
@* Submit and Reset Buttons *@ @* Submit and Reset Buttons *@
<div class="form-group row"> <div class="form-group row">
<div class="col-sm-8 offset-sm-3"> <div class="col-sm-8 offset-sm-3">
<button type="submit" class="btn btn-primary m-1">Return Item</button> <button type="submit" v-on:click="ReturnMessage" class="btn btn-primary m-1">Return Item</button>
</div> <button type="submit" v-on:click="StationMessage" class="btn btn-primary m-1" v-if="thisItem.currentStationId == null">Deploy Station</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@ -280,6 +230,68 @@
</div> </div>
</form> </form>
<!--STATION DEPLOY MESSAGE BOX INTERFACE-->
<div class="modal fade" id="stationMessage" tabindex="-1" role="dialog" aria-labelledby="stationModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="stationModalLabel">Deploy Station</h5>
<button type="button" class="close" data-dismiss="modal" v-on:click="closeStationMessageModal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form v-on:submit.prevent="updateStationItemMovement">
<div class="form-group row">
<label class="col-sm-4 col-form-label">Deploy Station : </label>
<div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStation">
<option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(station, index) in stationList" :key="index" :value="station.stationId">{{ station.stationName}}</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary">Deploy Station</button>
</form>
</div>
</div>
</div>
</div>
<!--RETURN MESSAGE BOX INTERFACE-->
<div class="modal fade" id="returnMessage" tabindex="-1" role="dialog" aria-labelledby="returnModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="returnModalLabel">Return Item</h5>
<button type="button" class="close" data-dismiss="modal" v-on:click="closeMessageModal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form v-on:submit.prevent="returnItemMovement">
<div class="form-group row">
<label class="col-sm-4 col-form-label">Remark:</label>
<div class="col-sm-8">
<input type="text" class="form-control" v-model="remark" />
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">Consignment Note:</label>
<div class="col-sm-8">
<input type="file" class="form-control-file" v-on:change="handleFileUpload" accept="image/png, image/jpeg, application/pdf" />
</div>
</div>
<button type="submit" class="btn btn-primary">Return Item</button>
</form>
</div>
</div>
</div>
</div>
<!--RECEIVE THEN RETURN INTERFACE --> <!--RECEIVE THEN RETURN INTERFACE -->
<div class="modal fade" id="returnModal" tabindex="-1" role="dialog" aria-labelledby="returnModalLabel" aria-hidden="true"> <div class="modal fade" id="returnModal" tabindex="-1" role="dialog" aria-labelledby="returnModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
@ -293,17 +305,6 @@
<div class="modal-body"> <div class="modal-body">
<form v-on:submit.prevent="receiveReturnAPI"> <form v-on:submit.prevent="receiveReturnAPI">
<!-- Station Dropdown -->
<div class="form-group row">
<label class="col-sm-4 col-form-label">Deploy Station : </label>
<div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStation">
<option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(station, index) in stationList" :key="index" :value="station.stationId">{{ station.stationName}}</option>
</select>
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-4 col-form-label">Remark:</label> <label class="col-sm-4 col-form-label">Remark:</label>
<div class="col-sm-8"> <div class="col-sm-8">
@ -375,7 +376,15 @@
qrCodeResult: null, qrCodeResult: null,
debounceTimeout: null, debounceTimeout: null,
error: "", 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 }, trackFunctionSelected: { text: 'outline', value: null },
barcodeFormats: { barcodeFormats: {
qr_code: true, // Hanya mendukung QR Code qr_code: true, // Hanya mendukung QR Code
@ -410,8 +419,8 @@
this.consignmentNote = null; this.consignmentNote = null;
} }
}, },
async updateItemMovement() {
async updateStationItemMovement() {
const requiredFields = ['selectedStation']; const requiredFields = ['selectedStation'];
for (let field of requiredFields) { 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 (this.receiveReturn == null) {
if (!confirm("Are you sure you already received this item?")) { if (!confirm("Are you sure you already received this item?")) {
return false; return false;
@ -430,8 +485,7 @@
try { try {
const now = new Date(); const now = new Date();
const formData = { const formData = {
Id: this.thisItem.movementId, Id : this.thisItem.id,
LastStation: this.selectedStation,
LatestStatus: "Delivered", LatestStatus: "Delivered",
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
MovementComplete: true MovementComplete: true
@ -463,6 +517,7 @@
alert('Inventory PSTW Error: An error occurred.'); alert('Inventory PSTW Error: An error occurred.');
} }
}, },
async returnItemMovement() { async returnItemMovement() {
const requiredFields = ['remark', 'consignmentNote']; 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) { 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"; 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"; this.displayStatus = "return";
} else if (this.thisItem.movementId != null && this.thisItem.toOther === "Return" && this.thisItem.latestStatus == null && this.thisItem.toUser == this.currentUserId) { } else if (this.thisItem.movementId != null && this.thisItem.toOther === "Return" && this.thisItem.latestStatus == null && this.thisItem.toUser == this.currentUserId) {
this.displayStatus = "requestAgain"; this.displayStatus = "requestAgain";
@ -625,10 +680,12 @@
} }
this.error = message; this.error = message;
}, },
//Setting Camera //Setting Camera
async onCameraReady() { async onCameraReady() {
try { this.enableAutoFocus();
},
async enableAutoFocus() {
const devices = await navigator.mediaDevices.enumerateDevices(); const devices = await navigator.mediaDevices.enumerateDevices();
this.videoInputDevices = devices.filter(device => device.kind === 'videoinput'); this.videoInputDevices = devices.filter(device => device.kind === 'videoinput');
@ -642,11 +699,19 @@
} else { } else {
this.error = "No camera detected."; this.error = "No camera detected.";
} }
} catch (err) {
this.error = "Error accessing camera: " + err.message;
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 //Update Camera Category
updateCamera() { updateCamera() {
this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } }; this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } };
@ -679,6 +744,22 @@
closeModal() { closeModal() {
$('#returnModal').modal('hide'); // Manually hide the modal $('#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); app.component("qrcode-stream", VueQrcodeReader.QrcodeStream);

View File

@ -496,6 +496,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
} }
var singleItem = new var singleItem = new
{ {
item.Movement?.Id,
item.ItemID, item.ItemID,
item.MovementId, item.MovementId,
item.UniqueID, item.UniqueID,
@ -853,20 +854,24 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{ {
if (!string.IsNullOrEmpty(request.Document)) 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); var bytes = Convert.FromBase64String(request.Document);
string filePath = ""; 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)) if (IsImage(bytes))
{ {
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/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/" + uniqueName + request.UserId + "_Request.jpg"; request.Document = "/media/inventory/request/" + findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "(" + uniqueAbjad + ") Request.jpg";
} }
else if (IsPdf(bytes)) else if (IsPdf(bytes))
{ {
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/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/" + uniqueName + request.UserId + "_Request.pdf"; request.Document = "/media/inventory/request/" + findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "(" + uniqueAbjad + ") Request.pdf";
} }
else else
{ {
@ -917,16 +922,17 @@ 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
.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 return Json(requests.Select(i => new
{ {
i.requestId, i.requestId,
productName = i.Product?.ProductName,
i.ProductId, i.ProductId,
productName = i.Product?.ProductName,
i.UserId, i.UserId,
i.status, i.status,
i.StationId, i.StationId,
stationName = i.Station?.StationName,
i.RequestQuantity, i.RequestQuantity,
i.requestDate, i.requestDate,
i.ProductCategory, i.ProductCategory,
@ -1195,7 +1201,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return NotFound("Item movement record not found."); return NotFound("Item movement record not found.");
} }
updatedList.LastStation = receiveMovement.LastStation;
updatedList.LatestStatus = receiveMovement.LatestStatus; updatedList.LatestStatus = receiveMovement.LatestStatus;
updatedList.receiveDate = receiveMovement.receiveDate; updatedList.receiveDate = receiveMovement.receiveDate;
updatedList.MovementComplete = receiveMovement.MovementComplete; updatedList.MovementComplete = receiveMovement.MovementComplete;
@ -1308,6 +1313,95 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return BadRequest(ex.Message); return BadRequest(ex.Message);
} }
} }
[HttpPost("StationItemMovementUser")]
public async Task<IActionResult> 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 #endregion
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB