Qr & Movement Display

This commit is contained in:
ArifHilmi 2025-03-04 14:36:04 +08:00
parent 4afac02583
commit eab78d321f
4 changed files with 410 additions and 86 deletions

View File

@ -36,27 +36,37 @@
.ms-auto { .ms-auto {
margin-left: auto !important; /* Push Complete/Incomplete to right */ margin-left: auto !important; /* Push Complete/Incomplete to right */
} }
</style> </style>
@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartialUser.cshtml") @await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartialUser.cshtml")
<div id="ItemMovement" class="row"> <div id="ItemMovement" class="row">
<div class="row mb-3"> <div class="row mb-3">
<h2 for="sortSelect" class="col-sm-1 col-form-h2" style="min-width:140px;">Sort by:</h2> <h2 for="sortSelect" class="col-sm-1 col-form-h2" style="min-width:150px;">Sort by:</h2>
<div class="col-sm-4"> <div class="col-sm-4">
<select id="sortSelect" class="form-control" v-model="sortBy" v-on:change="handleSorting"> <select id="sortSelect" class="form-control" v-model="sortBy" v-on:change="handleSorting">
<option value="all">All</option> <option value="all">All</option>
<option value="item">Item</option> <option value="item">Item</option>
<option value="station">Station</option>
</select> </select>
</div> </div>
</div> </div>
<div class="row mb-3" v-if="sortBy === 'item'"> <div class="row mb-3" v-if="sortBy === 'item'">
<h4 class="col-sm-1 col-form-h2" style="min-width:140px;">Search Item:</h4> <h4 class="col-sm-1 col-form-h2" style="min-width:150px;">Search Item:</h4>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" v-model="searchQuery" placeholder="Search by item code..."> <input type="text" class="form-control" v-model="searchQuery" placeholder="Search by item code...">
</div> </div>
</div> </div>
<div class="row mb-3" v-if="sortBy === 'station'">
<h4 class="col-sm-1 col-form-h2" style="min-width:150px;">Search Station:</h4>
<div class="col-sm-4">
<input type="text" class="form-control" v-model="searchStation" placeholder="Search by station name...">
</div>
</div>
<div v-if="sortBy === 'all'"> <div v-if="sortBy === 'all'">
<div class="row card"> <div class="row card">
<div class="card-header"> <div class="card-header">
@ -77,6 +87,7 @@
</div> </div>
</div> </div>
<!--------------------------------------------ITEM CATEGORY---------------------------------------------------------------------->
<div v-if="sortBy === 'item'"> <div v-if="sortBy === 'item'">
<div v-for="(group, itemId) in filteredItems" :key="itemId" class="row card"> <div v-for="(group, itemId) in filteredItems" :key="itemId" class="row card">
<div class="card-header d-flex justify-content-between align-items-center"> <div class="card-header d-flex justify-content-between align-items-center">
@ -94,11 +105,16 @@
<strong>Latest Movement</strong> <strong>Latest Movement</strong>
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<!-- Movement Type --> <!-- Movement Type -->
<h3 :class="movement.toOther === 'On Delivery' ? 'text-primary' : 'text-warning'" <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther !== 'On Delivery' && movement.action !== 'Assign',
class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;"> 'text-info': movement.action === 'Assign'}"
{{ movement.toOther === 'On Delivery' ? 'Receive' : 'Return' }} class="flex-shrink-0 text-nowrap"
style="max-width:90px; min-width:90px;">
{{ movement.action === 'Assign' ? 'Assign' : (movement.toOther === 'On Delivery' ? 'Receive' : 'Return') }}
</h3> </h3>
<!-- Send Date --> <!-- Send Date -->
<div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1"> <div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1">
<h4 class="fixed-label m-0 text-nowrap">Send Date:</h4> <h4 class="fixed-label m-0 text-nowrap">Send Date:</h4>
@ -143,33 +159,34 @@
<i v-if="movement.toOther !== 'On Delivery'" class="fas fa-user fa-2x"></i> <i v-if="movement.toOther !== 'On Delivery'" class="fas fa-user fa-2x"></i>
<i v-else class="fas fa-warehouse fa-2x"></i> <i v-else class="fas fa-warehouse fa-2x"></i>
<p><strong>Start</strong></p> <p><strong>Start</strong></p>
<p><strong>User:</strong> {{ movement.toUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p><strong>Station:</strong> {{ movement.toStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p><strong>Store:</strong> {{ movement.toStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<p></p> <p></p>
<i class="fas fa-arrow-right fa-2x"></i> <i class="fas fa-arrow-right fa-2x"></i>
<p>{{ movement.latestStatus || movement.toOther }}</p> <p>{{ movement.latestStatus || movement.toOther }}</p>
<p> <p>
<button class="btn btn-info btn-sm ms-auto" v-on:click="remark(movement.remark)" v-if="movement.toOther !== 'On Delivery'"> <button class="btn btn-info btn-sm ms-auto" v-on:click="remark(movement.remark)">
Remark Remark
</button> </button>
</p> </p>
<p> <p>
<button class="btn btn-info btn-sm ms-auto" v-on:click="consignmentNote(movement.consignmentNote)" v-if="movement.toOther !== 'On Delivery'"> <button class="btn btn-info btn-sm ms-auto" v-on:click="consignmentNote(movement.consignmentNote)">
Consignment Note Consignment Note
</button> </button>
</p> </p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<!-- Conditionally render End Icon --> <!-- Conditionally render End Icon -->
<i v-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i>
<i v-v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -186,9 +203,13 @@
<div v-for="(movement, i) in group.movements.slice(1)" :key="i" class="row mt-2"> <div v-for="(movement, i) in group.movements.slice(1)" :key="i" class="row mt-2">
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<!-- Movement Type --> <!-- Movement Type -->
<h3 :class="movement.toOther === 'On Delivery' ? 'text-primary' : 'text-warning'" <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther !== 'On Delivery' && movement.action !== 'Assign',
class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;"> 'text-info': movement.action === 'Assign'}"
{{ movement.toOther === 'On Delivery' ? 'Receive' : 'Return' }} class="flex-shrink-0 text-nowrap"
style="max-width:90px; min-width:90px;">
{{ movement.action === 'Assign' ? 'Assign' : (movement.toOther === 'On Delivery' ? 'Receive' : 'Return') }}
</h3> </h3>
<!-- Send Date --> <!-- Send Date -->
@ -236,33 +257,34 @@
<i v-if="movement.toOther !== 'On Delivery'" class="fas fa-user fa-2x"></i> <i v-if="movement.toOther !== 'On Delivery'" class="fas fa-user fa-2x"></i>
<i v-else class="fas fa-warehouse fa-2x"></i> <i v-else class="fas fa-warehouse fa-2x"></i>
<p><strong>Start</strong></p> <p><strong>Start</strong></p>
<p><strong>User:</strong> {{ movement.toUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p><strong>Station:</strong> {{ movement.toStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p><strong>Store:</strong> {{ movement.toStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<p></p> <p></p>
<i class="fas fa-arrow-right fa-2x"></i> <i class="fas fa-arrow-right fa-2x"></i>
<p>{{ movement.latestStatus || movement.toOther }}</p> <p>{{ movement.latestStatus || movement.toOther }}</p>
<p> <p>
<button class="btn btn-info btn-sm ms-auto" v-on:click="remark(movement.remark)" v-if="movement.toOther !== 'On Delivery'"> <button class="btn btn-info btn-sm ms-auto" v-on:click="remark(movement.remark)">
Remark Remark
</button> </button>
</p> </p>
<p> <p>
<button class="btn btn-info btn-sm ms-auto" v-on:click="consignmentNote(movement.consignmentNote)" v-if="movement.toOther !== 'On Delivery'"> <button class="btn btn-info btn-sm ms-auto" v-on:click="consignmentNote(movement.consignmentNote)">
Consignment Note Consignment Note
</button> </button>
</p> </p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<!-- Conditionally render End Icon --> <!-- Conditionally render End Icon -->
<i v-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -272,7 +294,214 @@
</div> </div>
</div> </div>
</div>
<!--------------------------------------------STATION CATEGORY---------------------------------------------------------------------->
<div v-if="sortBy === 'station'">
<div v-for="(items, station) in filteredStation" :key="stationName" :class="{'bg-light-gray': station === 'Unassign Station', 'bg-white': station !== 'Unassign Station'}" class="station-category card mt-3">
<!-- 📌 Station Header -->
<div class="card-header d-flex justify-content-between align-items-center">
<h3>{{ station }}</h3>
<button class="btn btn-light" v-on:click="toggleCategory(station)">
<i :class="categoryVisible[station] ? 'fas fa-chevron-up' : 'fas fa-chevron-down'"></i> Show Items
</button>
</div>
<!-- 📌 Show Items Under Each Station -->
<div v-show="categoryVisible[station]" class="card-body">
<div v-for="(group, itemId) in items" :key="itemId" class="row card">
<!-- 📌 Item Header -->
<div class="card-header d-flex justify-content-between align-items-center">
<h2>Item : {{ group.uniqueID }}</h2>
<button class="btn btn-light" v-on:click="toggleCategory(itemId)">
<i :class="categoryVisible[itemId] ? 'fas fa-chevron-up' : 'fas fa-chevron-down'"></i> Show Details
</button>
</div>
<!-- 📌 Show Movements for Each Item -->
<div v-show="categoryVisible[itemId]" class="card-body">
<div v-for="(movement, index) in group.movements.sort((a, b) => a.id - b.id).reverse()" :key="movement.id" class="movement-row">
<div v-if="index === 0" class="row">
<strong>Latest Movement</strong>
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther !== 'On Delivery' && movement.action !== 'Assign',
'text-info': movement.action === 'Assign'}"
class="flex-shrink-0 text-nowrap"
style="max-width:90px; min-width:90px;">
{{ movement.action === 'Assign' ? 'Assign' : (movement.toOther === 'On Delivery' ? 'Receive' : 'Return') }}
</h3>
<div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1">
<h4 class="fixed-label m-0 text-nowrap">Send Date:</h4>
<span class="fixed-value">{{ movement.sendDate }}</span>
</div>
<div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1">
<h4 class="fixed-label m-0 text-nowrap">Receive Date:</h4>
<span class="fixed-value">{{ movement.receiveDate || 'Not arrive' }}</span>
</div>
<div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1">
<h4 class="fixed-labelStatus m-0 text-nowrap">Action:</h4>
<span class="fixed-value">{{ movement.action }}</span>
</div>
<div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1">
<h4 class="fixed-labelStatus m-0 text-nowrap">Status:</h4>
<span class="fixed-value">{{ movement.latestStatus || movement.toOther }}</span>
</div>
<button class="btn btn-info btn-sm ms-auto" v-on:click="toggleDetails(movement.id)">
More Details
</button>
<h4 :class="movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : 'text-danger'" class="text-nowrap ms-3">
{{ movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete') }}
</h4>
</div>
<div v-show="detailsVisible[movement.id]" class="col-md-12 mt-2">
<div class="row">
<div class="col-md-4 text-center">
<i v-if="movement.toOther !== 'On Delivery'" class="fas fa-user fa-2x"></i>
<i v-else class="fas fa-warehouse fa-2x"></i>
<p><strong>Start</strong></p>
<p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div>
<div class="col-md-4 text-center">
<i class="fas fa-arrow-right fa-2x"></i>
<p>{{ movement.latestStatus || movement.toOther }}</p>
<p>
<button class="btn btn-info btn-sm ms-auto" v-on:click="remark(movement.remark)">
Remark
</button>
</p>
<p>
<button class="btn btn-info btn-sm ms-auto" v-on:click="consignmentNote(movement.consignmentNote)">
Consignment Note
</button>
</p>
</div>
<div class="col-md-4 text-center">
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div>
</div>
</div>
</div>
</div>
<!-- 📌 Single View History Button -->
<button class="btn btn-light w-100 text-left" v-on:click="toggleHistory(itemId)">
<i :class="historyVisible[itemId] ? 'fas fa-chevron-up' : 'fas fa-chevron-down'"></i> View History
</button>
<div v-show="historyVisible[itemId]" class="history-row">
<div v-for="(movement, i) in group.movements.slice(1)" :key="i" class="row mt-2">
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<!-- Movement Type -->
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther !== 'On Delivery' && movement.action !== 'Assign',
'text-info': movement.action === 'Assign'}" class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;">
{{ movement.action === 'Assign' ? 'Assign' : (movement.toOther === 'On Delivery' ? 'Receive' : 'Return') }}
</h3>
<!-- Send Date -->
<div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1" style="max-width:285px; min-width:285px;">
<h4 class="fixed-label m-0 text-nowrap">Send Date:</h4>
<span class="fixed-value text-truncate">{{ movement.sendDate }}</span>
</div>
<!-- Receive Date -->
<div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1" style="max-width:290px; min-width:290px;">
<h4 class="fixed-label m-0 text-nowrap">Receive Date:</h4>
<span class="fixed-value text-truncate" style="max-width:160px;">{{ movement.receiveDate || 'Not arrive' }}</span>
</div>
<!-- Action -->
<div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1" style="max-width:150px; min-width:150px;">
<h4 class="fixed-labelStatus m-0 text-nowrap">Action:</h4>
<span class="fixed-value text-truncate">{{ movement.action }}</span>
</div>
<!-- Status -->
<div class="d-flex flex-wrap align-items-center gap-2 flex-grow-1" style="max-width:160px; min-width:160px;">
<h4 class="fixed-labelStatus m-0 text-nowrap">Status:</h4>
<span class="fixed-value text-truncate" style="max-width:90px;">{{ movement.latestStatus || movement.toOther }}</span>
</div>
<!-- More Details Button -->
<button class="btn btn-info btn-sm ms-auto" v-on:click="toggleDetails(movement.id)">
More Details
</button>
<!-- Completion Status -->
<h4 :class="movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : 'text-danger'"
class="text-nowrap ms-3">
{{ movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete') }}
</h4>
</div>
<!-- 📌 Details Section (Hidden by Default) -->
<div v-show="detailsVisible[movement.id]" class="col-md-12 mt-2">
<div class="row">
<div class="col-md-4 text-center">
<!-- Conditionally render Start Icon -->
<i v-if="movement.toOther !== 'On Delivery'" class="fas fa-user fa-2x"></i>
<i v-else class="fas fa-warehouse fa-2x"></i>
<p><strong>Start</strong></p>
<p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div>
<div class="col-md-4 text-center">
<p></p>
<i class="fas fa-arrow-right fa-2x"></i>
<p>{{ movement.latestStatus || movement.toOther }}</p>
<p>
<button class="btn btn-info btn-sm ms-auto" v-on:click="remark(movement.remark)">
Remark
</button>
</p>
<p>
<button class="btn btn-info btn-sm ms-auto" v-on:click="consignmentNote(movement.consignmentNote)">
Consignment Note
</button>
</p>
</div>
<div class="col-md-4 text-center">
<!-- Conditionally render End Icon -->
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--------------------------------------------REMARK & CONSIGNMENT NOTE CATEGORY---------------------------------------------------------------------->
<div class="modal fade" id="remarkModal" tabindex="-1" aria-labelledby="remarkModalLabel" aria-hidden="true"> <div class="modal fade" id="remarkModal" tabindex="-1" aria-labelledby="remarkModalLabel" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
@ -304,9 +533,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
@section Scripts { @section Scripts {
@ -324,11 +550,13 @@
itemMovementCompleteDatatable: null, itemMovementCompleteDatatable: null,
itemMovementNotCompleteDatatable: null, itemMovementNotCompleteDatatable: null,
searchQuery: "", searchQuery: "",
searchStation: "",
sortBy: "all", sortBy: "all",
historyVisible: {}, historyVisible: {},
detailsVisible: {}, detailsVisible: {},
categoryVisible: {}, categoryVisible: {},
consignmentNoteUrl: "", consignmentNoteUrl: "",
stationName: "",
}; };
}, },
computed: { computed: {
@ -344,6 +572,37 @@
return acc; return acc;
}, {}); }, {});
}, },
groupedByStation() {
let grouped = {};
this.itemMovements.forEach((movement) => {
let station = movement.toStationName || movement.lastStationName || "Unassign Station";
let itemId = movement.uniqueID;
if (!grouped[station]) {
grouped[station] = {};
}
if (!grouped[station][itemId]) {
grouped[station][itemId] = { uniqueID: itemId, movements: [] };
}
grouped[station][itemId].movements.push(movement);
});
// Sort stations and move "Unassign Station" to the last position
let sortedKeys = Object.keys(grouped).sort((a, b) => {
if (a === "Unassign Station") return 1; // Move Unassign Station to the end
if (b === "Unassign Station") return -1;
return a.localeCompare(b); // Normal sorting for other stations
});
let sortedGrouped = {};
sortedKeys.forEach((key) => {
sortedGrouped[key] = grouped[key];
});
return sortedGrouped;
},
filteredItems() { filteredItems() {
if (!this.searchQuery.trim()) { if (!this.searchQuery.trim()) {
return this.groupedItems; return this.groupedItems;
@ -355,6 +614,23 @@
) )
); );
}, },
filteredStation() {
if (!this.searchStation) {
return this.groupedByStation;
}
let searchQuery = this.searchStation.toLowerCase();
let grouped = this.groupedByStation;
let filtered = {};
Object.keys(grouped).forEach(station => {
if (station.toLowerCase().includes(searchQuery)) {
filtered[station] = grouped[station];
}
});
return filtered;
},
}, },
mounted() { mounted() {
this.fetchItemMovement(); this.fetchItemMovement();
@ -382,7 +658,6 @@
}); });
}, },
async fetchItemMovement() { async fetchItemMovement() {
try { try {
const response = await fetch("/InvMainAPI/ItemMovementUser", { const response = await fetch("/InvMainAPI/ItemMovementUser", {

View File

@ -125,6 +125,7 @@
<div class="dropdown"> <div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-12" data-toggle="dropdown" aria-expanded="false" v-model="stationId" required> <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 v-if="stations.length === 0" class="btn-light" disabled>No Station Assigned to You</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 }}
</option> </option>
@ -218,9 +219,9 @@
}, },
async mounted() { async mounted() {
this.fetchProducts(); this.fetchProducts();
this.fetchStation();
await this.fetchUser(); await this.fetchUser();
await Promise.all([ await Promise.all([
this.fetchStation(),
this.fetchRequest(), this.fetchRequest(),
]); ]);
}, },
@ -574,7 +575,9 @@
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to fetch suppliers'); throw new Error('Failed to fetch suppliers');
} }
this.stations = await response.json(); // Get the full response object
const data = await response.json();
this.stations = data.filter(station => station.stationPicID === this.userId);
} catch (error) { } catch (error) {
console.error('Error fetching suppliers:', error); console.error('Error fetching suppliers:', error);

View File

@ -154,7 +154,7 @@
<div class="card shadow-sm border-0"> <div class="card shadow-sm border-0">
<div class="card-body"> <div class="card-body">
<h5 class="card-title mb-4 text-primary"> <h5 class="card-title mb-4 text-primary">
<i class="fas fa-info-circle me-2"></i>Receiver Information <i class="fas fa-info-circle me-2"></i>Sender Information
</h5> </h5>
<ul class="list-group list-group-flush"> <ul class="list-group list-group-flush">
<!-- User --> <!-- User -->
@ -164,7 +164,7 @@
<i class="fas fa-user me-2 text-secondary"></i>User: <i class="fas fa-user me-2 text-secondary"></i>User:
</span> </span>
<span class="text-muted text-end" style="max-width: 70%; word-wrap: break-word;"> <span class="text-muted text-end" style="max-width: 70%; word-wrap: break-word;">
{{ thisItem.toUserName }} {{ thisItem.currentUser }}
</span> </span>
</div> </div>
</li> </li>
@ -191,8 +191,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-5">
<button type="button" v-on:click="ReturnMessage" class="btn btn-secondary m-1">Return Item</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 Item</button> <button type="submit" class="btn btn-primary m-1">Receive Item</button>
</div> </div>
</div> </div>
@ -217,7 +217,7 @@
<br><br> <br><br>
@* 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-5">
<button type="submit" v-on:click="ReturnMessage" 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>
<button type="submit" v-on:click="StationMessage" class="btn btn-primary m-1" v-if="thisItem.currentStationId == null">Deploy Station</button> <button type="submit" v-on:click="StationMessage" class="btn btn-primary m-1" v-if="thisItem.currentStationId == null">Deploy Station</button>
</div> </div>
@ -248,6 +248,7 @@
<div class="col-sm-8"> <div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStation"> <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" value="" disabled selected>Select Station</option>
<option v-if="stationList.length === 0" class="btn-light" disabled>No Station Assigned to You</option>
<option class="btn-light" v-for="(station, index) in stationList" :key="index" :value="station.stationId">{{ station.stationName}}</option> <option class="btn-light" v-for="(station, index) in stationList" :key="index" :value="station.stationId">{{ station.stationName}}</option>
</select> </select>
</div> </div>
@ -371,6 +372,7 @@
consignmentNote: null, consignmentNote: null,
receiveReturn: null, receiveReturn: null,
UniqueID: null, UniqueID: null,
InventoryMasterId: null,
//QR VARIABLE //QR VARIABLE
qrCodeResult: null, qrCodeResult: null,
@ -399,10 +401,12 @@
selectedCameraId: null, selectedCameraId: null,
}; };
}, },
mounted() { async mounted() {
this.trackFunctionSelected.value = this.paintOutline; this.trackFunctionSelected.value = this.paintOutline;
this.fetchStation(); await this.fetchUser();
this.fetchUser(); await Promise.all([
this.fetchStation(),
]);
}, },
methods: { methods: {
@ -435,7 +439,7 @@
const formData = { const formData = {
ItemId: this.thisItem.itemID, ItemId: this.thisItem.itemID,
ToStation: this.thisItem.currentStationId, ToStation: this.thisItem.currentStationId,
ToStore: this.thisItem.currentStoreId, ToStore: this.thisItem.toStore,
ToUser: this.currentUserId, ToUser: this.currentUserId,
ToOther: "Delivered", ToOther: "Delivered",
SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
@ -461,10 +465,11 @@
}); });
if (response.ok) { if (response.ok) {
this.thisItem = await response.json();
this.fetchItem(this.thisItem.uniqueID);
alert('Success! Item assign to the Station.'); alert('Success! Item assign to the Station.');
$('#stationMessage').modal('hide'); $('#stationMessage').modal('hide');
this.displayStatus = "return"; this.displayStatus = "return";
this.thisItem = await response.json();
} else { } else {
throw new Error('Failed to submit form.'); throw new Error('Failed to submit form.');
} }
@ -488,7 +493,7 @@
Id : this.thisItem.id, Id : this.thisItem.id,
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,
}; };
const response = await fetch('/InvMainAPI/UpdateItemMovementUser', { const response = await fetch('/InvMainAPI/UpdateItemMovementUser', {
@ -520,14 +525,14 @@
async returnItemMovement() { async returnItemMovement() {
const requiredFields = ['remark', 'consignmentNote']; // const requiredFields = ['remark', 'consignmentNote'];
for (let field of requiredFields) { // for (let field of requiredFields) {
if (!this[field]) { // if (!this[field]) {
alert(`Request Error: Please fill in required field ${field}.`, 'warning'); // alert(`Request Error: Please fill in required field ${field}.`, 'warning');
return; // return;
} // }
} // }
if (!confirm("Are you sure you want to return this item?")) { if (!confirm("Are you sure you want to return this item?")) {
return false; return false;
@ -547,7 +552,7 @@
Remark: this.remark, Remark: this.remark,
ConsignmentNote: this.consignmentNote, ConsignmentNote: this.consignmentNote,
Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
LastUser: this.thisItem.toUser, LastUser: this.InventoryMasterId,
LastStore: this.thisItem.toStore, LastStore: this.thisItem.toStore,
LastStation: this.thisItem.toStation, LastStation: this.thisItem.toStation,
LatestStatus: null, LatestStatus: null,
@ -567,6 +572,7 @@
alert('Success! Item is on the delivery to return to Inventory Master.'); alert('Success! Item is on the delivery to return to Inventory Master.');
this.thisItem = await response.json(); this.thisItem = await response.json();
$('#returnModal').modal('hide'); $('#returnModal').modal('hide');
$('#returnMessage').modal('hide');
this.displayStatus = "requestAgain"; this.displayStatus = "requestAgain";
this.resetForm(); this.resetForm();
} else { } else {
@ -585,7 +591,9 @@
); );
if (response.ok) { if (response.ok) {
this.thisItem = await response.json(); this.thisItem = await response.json();
this.fetchStore(this.thisItem.toStore);
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";
@ -616,7 +624,28 @@
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to fetch suppliers'); throw new Error('Failed to fetch suppliers');
} }
this.stationList = await response.json(); // Get the full response object
const data = await response.json();
this.stationList = data.filter(station => station.stationPicID === this.currentUserId);
} catch (error) {
console.error('Error fetching suppliers:', error);
}
},
async fetchStore(storeId) {
try {
const response = await fetch('/InvMainAPI/StoreSpecificMaster/' + storeId, {
method: 'POST', // Specify the HTTP method
headers: {
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error('Failed to fetch Store');
}
const data = await response.json();
this.InventoryMasterId = data.userId;
} catch (error) { } catch (error) {
console.error('Error fetching suppliers:', error); console.error('Error fetching suppliers:', error);

View File

@ -1171,6 +1171,12 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return Json(storeList); return Json(storeList);
} }
[HttpPost("StoreSpecificMaster/{storeId}")]
public async Task<IActionResult> StoreSpecificMaster(int storeId)
{
var storeList = await _centralDbContext.InventoryMasters.Where(i => i.StoreId == storeId).FirstOrDefaultAsync();
return Json(storeList);
}
#endregion Store #endregion Store
@ -1280,9 +1286,19 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
returnItems.ItemStatus = 2; returnItems.ItemStatus = 2;
_centralDbContext.Items.Update(returnItems); _centralDbContext.Items.Update(returnItems);
}
}
//4. Update Assign Row (Untuk ToStore = Ada value , kepada , ToStore = null)
var updateToStoreAssignStation = await _centralDbContext.ItemMovements.Where(i => i.Action == "Assign").ToListAsync();
foreach (var item in updateToStoreAssignStation)
{
item.ToStore = null; // Set ToStore to null for each matching row
_centralDbContext.ItemMovements.Update(item);
}
await _centralDbContext.SaveChangesAsync(); // Simpan perubahan await _centralDbContext.SaveChangesAsync(); // Simpan perubahan
}
}
return Json(new return Json(new
{ {
@ -1353,7 +1369,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
await _centralDbContext.SaveChangesAsync(); await _centralDbContext.SaveChangesAsync();
// 2. Cari item movement yang ada ItemId & MovementComplete = false // 2. Cari item movement yang ada ItemId & MovementComplete = false
var updateItemIdMovement = await _centralDbContext.ItemMovements var updateItemIdMovement = await _centralDbContext.ItemMovements.Include(i => i.Item)
.FirstOrDefaultAsync(m => m.Id == stationMovement.Id); .FirstOrDefaultAsync(m => m.Id == stationMovement.Id);
@ -1366,9 +1382,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{ {
returnItems.MovementId = updateItemIdMovement.Id; returnItems.MovementId = updateItemIdMovement.Id;
returnItems.ItemStatus = 3; returnItems.ItemStatus = 3;
_centralDbContext.Items.Update(returnItems);
await _centralDbContext.SaveChangesAsync(); // Simpan perubahan _centralDbContext.Items.Update(returnItems); // Simpan perubahan
await _centralDbContext.SaveChangesAsync();
} }
} }
@ -1376,6 +1392,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{ {
updateItemIdMovement.Id, updateItemIdMovement.Id,
updateItemIdMovement.ItemId, updateItemIdMovement.ItemId,
updateItemIdMovement.Item?.UniqueID,
updateItemIdMovement.ToStation, updateItemIdMovement.ToStation,
updateItemIdMovement.ToStore, updateItemIdMovement.ToStore,
updateItemIdMovement.ToUser, updateItemIdMovement.ToUser,