update qr scanner
This commit is contained in:
parent
0f2b065c66
commit
43962646bb
@ -30,8 +30,9 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
|
|||||||
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")]
|
||||||
public virtual ItemModel? Item { get; set; }
|
|
||||||
[ForeignKey("ItemId")]
|
[ForeignKey("ItemId")]
|
||||||
|
public virtual ItemModel? Item { get; set; }
|
||||||
|
[ForeignKey("ToStore")]
|
||||||
public virtual StoreModel? NextStore { get; set; }
|
public virtual StoreModel? NextStore { get; set; }
|
||||||
[ForeignKey("ToStation")]
|
[ForeignKey("ToStation")]
|
||||||
public virtual StationModel? NextStation { get; set; }
|
public virtual StationModel? NextStation { get; set; }
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
<p v-show="currentUserCompanyDept.departmentName"><h2 class="display-6">Store: {{ currentUserCompanyDept.departmentName }}</h2></p>
|
<p v-show="currentUserCompanyDept.departmentName"><h2 class="display-6">Store: {{ currentUserCompanyDept.departmentName }}</h2></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml");
|
@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml")
|
||||||
<div class="row card">
|
<div class="row card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title">Inventory Report</h3>
|
<h3 class="card-title">Inventory Report</h3>
|
||||||
|
|||||||
@ -223,7 +223,7 @@
|
|||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<select class="btn btn-primary dropdown-toggle col-md-10" data-toggle="dropdown" aria-expanded="false" v-model="selectedSupplier" required>
|
<select class="btn btn-primary dropdown-toggle col-md-10" data-toggle="dropdown" aria-expanded="false" v-model="selectedSupplier" required>
|
||||||
<option class="btn-light" value="" disabled selected>Select Supplier</option>
|
<option class="btn-light" value="" disabled selected>Select Supplier</option>
|
||||||
<option class="btn-light" v-for="(item, index) in suppliers">{{ item.supplierName }}</option>
|
<option class="btn-light" v-for="(item, index) in suppliers" :value="item.supplierId">{{ item.supplierCompName }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -240,10 +240,6 @@
|
|||||||
try {
|
try {
|
||||||
const requiredFields = ['stationId', 'productId', 'quantity', 'productCategory'];
|
const requiredFields = ['stationId', 'productId', 'quantity', 'productCategory'];
|
||||||
|
|
||||||
this.userId = this.currentUser.id;
|
|
||||||
this.status = "Requested";
|
|
||||||
this.requestDate = new Date().toISOString();
|
|
||||||
|
|
||||||
// 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) {
|
||||||
if (!this[field]) {
|
if (!this[field]) {
|
||||||
@ -252,6 +248,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.userId = this.currentUser.id;
|
||||||
|
this.status = "Requested";
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
this.requestDate = new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString();
|
||||||
|
|
||||||
|
|
||||||
// Prepare data as JSON (No file upload)
|
// Prepare data as JSON (No file upload)
|
||||||
const requestData = {
|
const requestData = {
|
||||||
ProductId: this.productId,
|
ProductId: this.productId,
|
||||||
|
|||||||
@ -32,10 +32,16 @@
|
|||||||
<h1 data-aos="fade-right">QR & Barcode Scanner</h1>
|
<h1 data-aos="fade-right">QR & Barcode Scanner</h1>
|
||||||
<div id="reader" data-aos="fade-right"></div>
|
<div id="reader" data-aos="fade-right"></div>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus != null">
|
|
||||||
|
<!--RECEIVE OR RETURN INTERFACE -->
|
||||||
|
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived'">
|
||||||
<h2>Item Receive Information :</h2>
|
<h2>Item Receive Information :</h2>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="displayStatus != null" style="display: flex; justify-content: center; align-items: center;">
|
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'return'">
|
||||||
|
<h2>Item Return Information :</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="displayStatus === 'arrived' || displayStatus === 'return'" style="display: flex; justify-content: center; align-items: center;">
|
||||||
|
|
||||||
<div class="col-lg-7 col-11 border rounded p-3 shadow-sm">
|
<div class="col-lg-7 col-11 border rounded p-3 shadow-sm">
|
||||||
<div class="row m-3 d-flex align-items-center justify-content-center">
|
<div class="row m-3 d-flex align-items-center justify-content-center">
|
||||||
@ -81,7 +87,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Current Information Card -->
|
<!--RECIEVE INTERFACE -->
|
||||||
<div class="col-12" v-if="displayStatus === 'arrived'">
|
<div class="col-12" v-if="displayStatus === 'arrived'">
|
||||||
<div class="card shadow-sm border-0">
|
<div class="card shadow-sm border-0">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -121,10 +127,51 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--RETURN INTERFACE -->
|
||||||
|
<div class="col-12" v-if="displayStatus === 'return'">
|
||||||
|
<div class="card shadow-sm border-0">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title mb-4 text-primary">
|
||||||
|
<i class="fas fa-info-circle me-2"></i>Receiver Information
|
||||||
|
</h5>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<!-- User -->
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="d-flex justify-content-between align-items-start">
|
||||||
|
<span class="fw-bold">
|
||||||
|
<i class="fas fa-user me-2 text-secondary"></i>User:
|
||||||
|
</span>
|
||||||
|
<span class="text-muted text-end" style="max-width: 70%; word-wrap: break-word;">
|
||||||
|
{{ thisItem.toUserName }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--RECIEVE INTERFACE -->
|
||||||
<form v-on:submit.prevent="updateItemMovement" v-if="displayStatus === 'arrived'" data-aos="fade-right">
|
<form v-on:submit.prevent="updateItemMovement" v-if="displayStatus === 'arrived'" 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">
|
||||||
@ -155,8 +202,8 @@
|
|||||||
@* 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="resetForm" class="btn btn-secondary m-1">Return</button>
|
<button type="button" v-on:click="receiveReturnMessage" class="btn btn-secondary m-1">Return Item</button>
|
||||||
<button type="submit" class="btn btn-primary m-1">Receive</button>
|
<button type="submit" class="btn btn-primary m-1">Receive Item</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -165,8 +212,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!--RETURN INTERFACE -->
|
||||||
<form v-on:submit.prevent="returnItemMovement" v-if="displayStatus === 'return'" data-aos="fade-right">
|
<form v-on:submit.prevent="returnItemMovement" 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">
|
||||||
@ -201,8 +250,7 @@
|
|||||||
@* 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="resetForm" class="btn btn-secondary m-1">Return</button>
|
<button type="submit" class="btn btn-primary m-1">Return Item</button>
|
||||||
<button type="submit" class="btn btn-primary m-1">Receive</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -213,6 +261,66 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!--RECEIVE THEN RETURN INTERFACE -->
|
||||||
|
<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-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="closeModal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<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">
|
||||||
|
<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="text" class="form-control" v-model="consignmentNote" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Return Item</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ALREADY RETURN ITEM INTERFACE -->
|
||||||
|
<div v-if="displayStatus === 'requestAgain'" class="d-flex justify-content-center align-items-center vh-100">
|
||||||
|
<div class="col-lg-10 col-11 border rounded p-5 shadow-lg text-center min-vh-50">
|
||||||
|
<h1 class="text-danger">The item has been register as returned.</h1>
|
||||||
|
<h3 class="text-muted">You need to request this item again to used it legally.</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- NOT SIGN IN ITEM INTERFACE -->
|
||||||
|
<div v-if="displayStatus === 'differentUser'" class="d-flex justify-content-center align-items-center vh-100">
|
||||||
|
<div class="col-lg-10 col-11 border rounded p-5 shadow-lg text-center min-vh-50">
|
||||||
|
<h1 class="text-danger">The item is not assigned to you.</h1>
|
||||||
|
<h3 class="text-muted">You need to request this item to validly use it.</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -240,7 +348,11 @@
|
|||||||
debounceTime: 500,
|
debounceTime: 500,
|
||||||
currentUser: null,
|
currentUser: null,
|
||||||
movementId: null,
|
movementId: null,
|
||||||
currentUserId:null,
|
currentUserId: null,
|
||||||
|
remark: null,
|
||||||
|
consignmentNote: null,
|
||||||
|
receiveReturn: null,
|
||||||
|
UniqueID : null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -250,18 +362,29 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async updateItemMovement() {
|
async updateItemMovement() {
|
||||||
if (!confirm("Are you sure you already receive this item?")) {
|
|
||||||
return false;
|
const requiredFields = ['selectedStation'];
|
||||||
|
|
||||||
|
for (let field of requiredFields) {
|
||||||
|
if (!this[field]) {
|
||||||
|
alert(`Request Error: Please fill in required field ${field}.`, 'warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.receiveReturn == null) {
|
||||||
|
if (!confirm("Are you sure you already received this item?")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Disable button
|
const now = new Date();
|
||||||
|
|
||||||
const formData = {
|
const formData = {
|
||||||
Id: this.thisItem.movementId,
|
Id: this.thisItem.movementId,
|
||||||
LastStation: this.selectedStation,
|
LastStation: this.selectedStation,
|
||||||
LatestStatus: "Delivered",
|
LatestStatus: "Delivered",
|
||||||
ReceiveDate: new Date().toISOString(),
|
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
|
||||||
MovementComplete: true
|
MovementComplete: true
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -274,10 +397,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
alert('Success! Item movement has been successfully submitted.');
|
if (this.receiveReturn == null) {
|
||||||
this.thisItem = await response.json();
|
alert('Success! Item has been successfully received.');
|
||||||
this.displayStatus = "return";
|
this.thisItem = await response.json();
|
||||||
this.resetForm();
|
this.displayStatus = "return";
|
||||||
|
this.fetchItem(this.UniqueID);
|
||||||
|
this.resetForm();
|
||||||
|
} else {
|
||||||
|
this.returnItemMovement();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Failed to submit form.');
|
throw new Error('Failed to submit form.');
|
||||||
}
|
}
|
||||||
@ -287,22 +415,43 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async returnItemMovement() {
|
async returnItemMovement() {
|
||||||
if (!confirm("Are you sure you already receive this item?")) {
|
|
||||||
|
const requiredFields = ['remark', 'consignmentNote'];
|
||||||
|
|
||||||
|
for (let field of requiredFields) {
|
||||||
|
if (!this[field]) {
|
||||||
|
alert(`Request Error: Please fill in required field ${field}.`, 'warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!confirm("Are you sure you want to return this item?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Disable button
|
const now = new Date();
|
||||||
|
|
||||||
const formData = {
|
const formData = {
|
||||||
Id: this.thisItem.movementId,
|
ItemId: this.thisItem.itemID,
|
||||||
LastStation: this.selectedStation,
|
ToStation: this.thisItem.currentStationId,
|
||||||
LatestStatus: "Delivered",
|
ToStore: this.thisItem.currentStoreId,
|
||||||
ReceiveDate: new Date().toISOString(),
|
ToUser: this.currentUserId,
|
||||||
MovementComplete: true
|
ToOther: "Return",
|
||||||
|
SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
|
||||||
|
Action: "StockIn",
|
||||||
|
Quantity: this.thisItem.quantity,
|
||||||
|
Remark: this.remark,
|
||||||
|
ConsignmentNote: this.consignmentNote,
|
||||||
|
Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
|
||||||
|
LastUser: this.thisItem.toUser,
|
||||||
|
LastStore: this.thisItem.toStore,
|
||||||
|
LastStation: this.thisItem.toStation,
|
||||||
|
LatestStatus: null,
|
||||||
|
ReceiveDate: null,
|
||||||
|
MovementComplete: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch('/InvMainAPI/UpdateItemMovementUser', {
|
const response = await fetch('/InvMainAPI/ReturnItemMovementUser', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -311,9 +460,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
alert('Success! Item movement has been successfully submitted.');
|
alert('Success! Item is on the delivery to return to Inventory Master.');
|
||||||
this.thisItem = await response.json();
|
this.thisItem = await response.json();
|
||||||
this.displayStatus = "return";
|
$('#returnModal').modal('hide');
|
||||||
|
this.displayStatus = "requestAgain";
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Failed to submit form.');
|
throw new Error('Failed to submit form.');
|
||||||
@ -326,7 +476,7 @@
|
|||||||
startScanner() {
|
startScanner() {
|
||||||
const config = {
|
const config = {
|
||||||
fps: 60,
|
fps: 60,
|
||||||
qrbox: 200
|
qrbox: 400
|
||||||
};
|
};
|
||||||
|
|
||||||
navigator.mediaDevices.getUserMedia({ video: true })
|
navigator.mediaDevices.getUserMedia({ video: true })
|
||||||
@ -336,6 +486,7 @@
|
|||||||
if (!this.debounceTimeout) {
|
if (!this.debounceTimeout) {
|
||||||
this.debounceTimeout = setTimeout(() => {
|
this.debounceTimeout = setTimeout(() => {
|
||||||
this.qrCodeResult = decodedText;
|
this.qrCodeResult = decodedText;
|
||||||
|
this.UniqueID = decodedText.split('/').pop();
|
||||||
this.fetchItem(decodedText.split('/').pop());
|
this.fetchItem(decodedText.split('/').pop());
|
||||||
this.debounceTimeout = null;
|
this.debounceTimeout = null;
|
||||||
}, this.debounceTime);
|
}, this.debounceTime);
|
||||||
@ -356,14 +507,15 @@
|
|||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
this.thisItem = await response.json();
|
this.thisItem = await response.json();
|
||||||
|
|
||||||
if (this.thisItem.movementId != null && this.thisItem.latestStatus == null && this.thisItem.currentUserId == this.currentUserId) {
|
if (this.thisItem.movementId != null && this.thisItem.toOther === "On Delivery" && this.thisItem.latestStatus == null && this.thisItem.currentUserId == this.currentUserId) {
|
||||||
this.displayStatus = "arrived";
|
this.displayStatus = "arrived";
|
||||||
} else if (this.thisItem.movementId != null && this.thisItem.toOther === "Delivered" && this.thisItem.currentUserId == this.currentUserId) {
|
} else if (this.thisItem.movementId != null && this.thisItem.toOther === "On Delivery" && this.thisItem.latestStatus != null && this.thisItem.currentUserId == this.currentUserId) {
|
||||||
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) {
|
||||||
|
this.displayStatus = "requestAgain";
|
||||||
} else {
|
} else {
|
||||||
this.displayStatus = "differentUser";
|
this.displayStatus = "differentUser";
|
||||||
this.thisItem = null;
|
this.thisItem = null;
|
||||||
this.displayStatus = null;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error('Failed to fetch item information');
|
console.error('Failed to fetch item information');
|
||||||
@ -409,6 +561,7 @@
|
|||||||
console.error('There was a problem with the fetch operation:', error);
|
console.error('There was a problem with the fetch operation:', error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
resetScanner() {
|
resetScanner() {
|
||||||
this.displayStatus = null;
|
this.displayStatus = null;
|
||||||
this.qrCodeResult = null;
|
this.qrCodeResult = null;
|
||||||
@ -416,9 +569,24 @@
|
|||||||
|
|
||||||
this.startScanner();
|
this.startScanner();
|
||||||
},
|
},
|
||||||
|
|
||||||
resetForm() {
|
resetForm() {
|
||||||
this.selectedStation = null;
|
this.selectedStation = null;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
async receiveReturnAPI() {
|
||||||
|
this.receiveReturn = 1;
|
||||||
|
console.log("update");
|
||||||
|
this.updateItemMovement();
|
||||||
|
},
|
||||||
|
|
||||||
|
receiveReturnMessage() {
|
||||||
|
$("#returnModal").modal("show");
|
||||||
|
},
|
||||||
|
|
||||||
|
closeModal() {
|
||||||
|
$('#returnModal').modal('hide'); // Manually hide the modal
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
<p v-show="currentUserCompanyDept.departmentName"><h2 class="display-6">Store: {{ currentUserCompanyDept.departmentName }}</h2></p>
|
<p v-show="currentUserCompanyDept.departmentName"><h2 class="display-6">Store: {{ currentUserCompanyDept.departmentName }}</h2></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartialUser.cshtml");
|
@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartialUser.cshtml")
|
||||||
</div>
|
</div>
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@{
|
@{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Azure.Core;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@ -328,6 +329,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
item.Product!.ProductShortName,
|
item.Product!.ProductShortName,
|
||||||
item.Product!.Category,
|
item.Product!.Category,
|
||||||
//CurrentUser = item.Movement?.FromUser?.UserName,
|
//CurrentUser = item.Movement?.FromUser?.UserName,
|
||||||
|
FromUser = item.Movement?.ToUser,
|
||||||
|
FromStore = item.Movement?.ToStore,
|
||||||
|
FromStation = item.Movement?.ToStation,
|
||||||
CurrentUser = item.Movement?.FromUser?.UserName,
|
CurrentUser = item.Movement?.FromUser?.UserName,
|
||||||
CurrentStore = item.Movement?.FromStore?.StoreName,
|
CurrentStore = item.Movement?.FromStore?.StoreName,
|
||||||
CurrentStation = item.Movement?.FromStation?.StationName,
|
CurrentStation = item.Movement?.FromStation?.StationName,
|
||||||
@ -480,7 +484,13 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
.Include(i => i.Movement)
|
.Include(i => i.Movement)
|
||||||
.ThenInclude(m => m!.FromStation)
|
.ThenInclude(m => m!.FromStation)
|
||||||
.Include(i => i.Movement)
|
.Include(i => i.Movement)
|
||||||
.ThenInclude(m => m!.FromUser).FirstOrDefaultAsync(i => i.UniqueID == id);
|
.ThenInclude(m => m!.FromUser)
|
||||||
|
.Include(i => i.Movement)
|
||||||
|
.ThenInclude(m => m!.NextStore)
|
||||||
|
.Include(i => i.Movement)
|
||||||
|
.ThenInclude(m => m!.NextStation)
|
||||||
|
.Include(i => i.Movement)
|
||||||
|
.ThenInclude(m => m!.NextUser).FirstOrDefaultAsync(i => i.UniqueID == id);
|
||||||
if (item == null){
|
if (item == null){
|
||||||
return NotFound(new { success = false, message = "Item not found" });
|
return NotFound(new { success = false, message = "Item not found" });
|
||||||
}
|
}
|
||||||
@ -514,7 +524,15 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
CurrentUser = item.Movement?.FromUser?.UserName,
|
CurrentUser = item.Movement?.FromUser?.UserName,
|
||||||
CurrentUserId = item.Movement?.FromUser?.Id,
|
CurrentUserId = item.Movement?.FromUser?.Id,
|
||||||
CurrentStore = item.Movement?.FromStore?.StoreName,
|
CurrentStore = item.Movement?.FromStore?.StoreName,
|
||||||
|
CurrentStoreId = item.Movement?.FromStore?.Id,
|
||||||
CurrentStation = item.Movement?.FromStation?.StationName,
|
CurrentStation = item.Movement?.FromStation?.StationName,
|
||||||
|
CurrentStationId = item.Movement?.FromStation?.StationId,
|
||||||
|
ToUser = item.Movement?.ToUser,
|
||||||
|
ToUserName = item.Movement?.NextUser?.UserName,
|
||||||
|
ToStore = item.Movement?.ToStore,
|
||||||
|
ToStoreName = item.Movement?.NextStore?.StoreName,
|
||||||
|
ToStation = item.Movement?.ToStation,
|
||||||
|
ToStationName = item.Movement?.NextStation?.StationName,
|
||||||
item.Movement?.ToOther,
|
item.Movement?.ToOther,
|
||||||
item.Movement?.LatestStatus,
|
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
|
||||||
@ -1065,6 +1083,16 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
_centralDbContext.ItemMovements.Update(updatedList);
|
_centralDbContext.ItemMovements.Update(updatedList);
|
||||||
await _centralDbContext.SaveChangesAsync();
|
await _centralDbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var receiveItems = await _centralDbContext.Items.FindAsync(receiveMovement.ItemId);
|
||||||
|
|
||||||
|
if (receiveItems != null)
|
||||||
|
{
|
||||||
|
receiveItems.ItemStatus = 3;
|
||||||
|
_centralDbContext.Items.Update(receiveItems);
|
||||||
|
|
||||||
|
await _centralDbContext.SaveChangesAsync(); // Simpan perubahan
|
||||||
|
}
|
||||||
|
|
||||||
return Json(updatedList);
|
return Json(updatedList);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -1084,33 +1112,53 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var updatedList = await _centralDbContext.ItemMovements
|
// 1. Simpan returnMovement dalam database
|
||||||
.Where(r => r.Id == returnMovement.Id)
|
_centralDbContext.ItemMovements.Add(returnMovement);
|
||||||
.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();
|
await _centralDbContext.SaveChangesAsync();
|
||||||
|
|
||||||
return Json(updatedList);
|
// 2. Cari item movement yang ada ItemId & MovementComplete = false
|
||||||
|
var updateItemIdMovement = await _centralDbContext.ItemMovements
|
||||||
|
.FirstOrDefaultAsync(m => m.ItemId == returnMovement.ItemId && m.MovementComplete == false);
|
||||||
|
|
||||||
|
|
||||||
|
// 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 = 2;
|
||||||
|
_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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,9 +1,19 @@
|
|||||||
@*
|
@*
|
||||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
*@
|
*@
|
||||||
|
@using Microsoft.AspNetCore.Identity
|
||||||
|
@inject SignInManager<UserModel> SignInManager
|
||||||
|
@inject UserManager<UserModel> UserManager
|
||||||
|
|
||||||
|
@{
|
||||||
|
var user = await UserManager.GetUserAsync(User);
|
||||||
|
var roles = user != null ? await UserManager.GetRolesAsync(user) : new List<string>();
|
||||||
|
|
||||||
|
Console.WriteLine("User Roles: " + string.Join(", ", roles));
|
||||||
|
var isNotTechnician = !roles.Any(r => r.Trim().Equals("Technician", StringComparison.OrdinalIgnoreCase));
|
||||||
|
Console.WriteLine("Is NOT Technician: " + (isNotTechnician ? "True" : "False"));
|
||||||
|
|
||||||
|
}
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html dir="ltr" lang="en">
|
<html dir="ltr" lang="en">
|
||||||
<head>
|
<head>
|
||||||
@ -433,18 +443,18 @@
|
|||||||
<i class="mdi mdi-receipt"></i><span class="hide-menu">Inventory </span>
|
<i class="mdi mdi-receipt"></i><span class="hide-menu">Inventory </span>
|
||||||
</a>
|
</a>
|
||||||
<ul aria-expanded="false" class="collapse first-level">
|
<ul aria-expanded="false" class="collapse first-level">
|
||||||
<li class="sidebar-item">
|
<li class="sidebar-item" v-if="@isNotTechnician">
|
||||||
<a class="sidebar-link waves-effect waves-dark sidebar-link"
|
<a class="sidebar-link waves-effect waves-dark sidebar-link"
|
||||||
asp-area="Inventory" asp-controller="InventoryMaster" asp-action="AdminDashboard"
|
asp-area="Inventory" asp-controller="InventoryMaster" asp-action="AdminDashboard"
|
||||||
aria-expanded="false">
|
aria-expanded="false">
|
||||||
<i class="mdi mdi-view-dashboard"></i><span class="hide-menu">AdminDashboard</span>
|
<i class="mdi mdi-view-dashboard"></i><span class="hide-menu">Admin Dashboard</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="sidebar-item">
|
<li class="sidebar-item">
|
||||||
<a class="sidebar-link waves-effect waves-dark sidebar-link"
|
<a class="sidebar-link waves-effect waves-dark sidebar-link"
|
||||||
asp-area="Inventory" asp-controller="ItemMovement" asp-action="UserDashboard"
|
asp-area="Inventory" asp-controller="ItemMovement" asp-action="UserDashboard"
|
||||||
aria-expanded="false">
|
aria-expanded="false">
|
||||||
<i class="mdi mdi-view-dashboard"></i><span class="hide-menu">UserDashboard</span>
|
<i class="mdi mdi-view-dashboard"></i><span class="hide-menu">User Dashboard</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="sidebar-item">
|
<li class="sidebar-item">
|
||||||
@ -748,6 +758,7 @@
|
|||||||
<!-- ============================================================== -->
|
<!-- ============================================================== -->
|
||||||
<!-- All Jquery -->
|
<!-- All Jquery -->
|
||||||
<!-- ============================================================== -->
|
<!-- ============================================================== -->
|
||||||
|
|
||||||
<script src="~/assets/libs/jquery/dist/jquery.min.js"></script>
|
<script src="~/assets/libs/jquery/dist/jquery.min.js"></script>
|
||||||
@* <script src="~/dist/js/jquery.ui.touch-punch-improved.js"></script> *@
|
@* <script src="~/dist/js/jquery.ui.touch-punch-improved.js"></script> *@
|
||||||
<script src="~/dist/js/jquery-ui.min.js"></script>
|
<script src="~/dist/js/jquery-ui.min.js"></script>
|
||||||
@ -783,7 +794,9 @@
|
|||||||
<script src="~/lib/html2canvas/dom-to-image.min.js"></script>
|
<script src="~/lib/html2canvas/dom-to-image.min.js"></script>
|
||||||
<!-- Datatables JS-->
|
<!-- Datatables JS-->
|
||||||
<script src="~/lib/datatables/datatables.js"></script>
|
<script src="~/lib/datatables/datatables.js"></script>
|
||||||
@await RenderSectionAsync("Scripts", required: false)z
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user