This commit is contained in:
MOHD ARIFF 2026-03-19 11:53:52 +08:00
parent 6535050179
commit 3fdfb9b312
2 changed files with 121 additions and 0 deletions

View File

@ -102,6 +102,12 @@
<li class="nav-item">
<button :class="['nav-link', {active: activeTab === 'storeTab'}]" v-on:click="activeTab = 'storeTab'">Store</button>
</li>
<li class="nav-item">
<button :class="['nav-link', {active: activeTab === 'stockIn'}]" v-on:click="activeTab = 'stockInTab'">Stock In</button>
</li>
<li class="nav-item">
<button :class="['nav-link', {active: activeTab === 'stockOut'}]" v-on:click="activeTab = 'stockOutTab'">Stock Out</button>
</li>
<li class="nav-item">
<button :class="['nav-link', {active: activeTab === 'allStoreTab'}]" v-on:click="activeTab = 'allStoreTab'">All Item</button>
</li>
@ -135,6 +141,22 @@
<table id="storeItemsTable" class="display table table-bordered table-hover"></table>
</div>
</div>
<div v-if="formResponse" v-show="activeTab === 'stockInTab'">
<div class="col-3">
<h4>Stock In</h4>
</div>
<div class="col-9">
<table id="stockInItemsTable" class="display table table-bordered table-hover"></table>
</div>
</div>
<div v-if="formResponse" v-show="activeTab === 'stockOutTab'">
<div class="col-3">
<h4>Stock Out</h4>
</div>
<div class="col-9">
<table id="stockOutItemsTable" class="display table table-bordered table-hover"></table>
</div>
</div>
<div v-if="formResponse" v-show="activeTab === 'allStoreTab'">
<div class="col-3">
<h4>Store</h4>
@ -194,6 +216,8 @@
selectedUser: [],
userItemsTable: null,
stationItemsTable: null,
stockInItemsTable: null,
stockOutItemsTable: null,
storeItemsTable: null,
storeAllItemsTable: null,
activeTab: "userTab"
@ -299,6 +323,14 @@
this.storeItemsTable.clear().destroy();
this.storeItemsTable = null;
}
if (this.stockInItemsTable) {
this.stockInItemsTable.clear().destroy();
this.stockInItemsTable = null;
}
if (this.stockOutItemsTable) {
this.stockOutItemsTable.clear().destroy();
this.stockOutItemsTable = null;
}
}
else {
console.error(`Failed to fetch user: ${response.statusText}`);
@ -471,6 +503,65 @@
});
}
});
const stockInItemTableData = this.formResponse.exactMonthStockIn ? this.formResponse.exactMonthStockIn : [];
this.stockInItemsTable = $('#stockInItemsTable').DataTable({
data: stockInItemTableData.items,
columns: [
{ data: 'itemName', title: 'Item Name' },
{ data: 'uniqueID', title: 'Unique ID' },
{ data: 'quantity', title: 'Quantity' },
{ data: 'from', title: 'From' },
{ data: 'to', title: 'To' },
{ data: 'price', title: 'Item Price' },
],
destroy: true,
drawCallback: function () {
const total = storeTableData.totalItemPrice;
// const total = stockInItemTableData.items.reduce((acc, item) => acc + item.price, 0) || 0;
$(this.api().table().node()).find('tbody tr.total-row').remove();
$(this.api().table().node()).find('tbody').append(
`<tr class="total-row">
<td colspan="3"><strong>Total</strong></td>
<td class="text-end"><strong>${total}</strong></td>
</tr>`
);
},
"createdRow": function (row, data, dataIndex) {
$(row).on('click', function () {
app.fetchItemMovement(data.uniqueID);
});
}
});
const stockOutItemTableData = this.formResponse.exactMonthStockOut ? this.formResponse.exactMonthStockOut : [];
console.log(stockOutItemTableData);
this.stockOutItemsTable = $('#stockOutItemsTable').DataTable({
data: stockOutItemTableData.items,
columns: [
{ data: 'itemName', title: 'Item Name' },
{ data: 'uniqueID', title: 'Unique ID' },
{ data: 'quantity', title: 'Quantity' },
{ data: 'from', title: 'From' },
{ data: 'to', title: 'To' },
{ data: 'price', title: 'Item Price' },
],
destroy: true,
drawCallback: function () {
const total = storeTableData.totalItemPrice;
// const total = stockOutItemTableData.items.reduce((acc, item) => acc + item.price, 0) || 0;
$(this.api().table().node()).find('tbody tr.total-row').remove();
$(this.api().table().node()).find('tbody').append(
`<tr class="total-row">
<td colspan="3"><strong>Total</strong></td>
<td class="text-end"><strong>${total}</strong></td>
</tr>`
);
},
"createdRow": function (row, data, dataIndex) {
$(row).on('click', function () {
app.fetchItemMovement(data.uniqueID);
});
}
});
const storeAllTableData = this.formResponse.allProductInStore ? this.formResponse.allProductInStore : [];
this.storeAllItemsTable = $('#storeAllItemsTable').DataTable({
data: storeAllTableData ,

View File

@ -183,6 +183,34 @@ namespace PSTW_CentralSystem.Controllers.API
.FirstOrDefault())
.ToListAsync();
var exactMonthStockOut = latestItemMovements
.Where(m => m != null && (m.Action!.ToLower() == "stockout" || m.Action!.ToLower() == "stock out") && m.Date.Month == parsedDate.Month)
.Select(m => new
{
UniqueID = m!.Item!.UniqueID,
From = m!.LastUser != null ? m.FromUser!.UserName : m.LastStore != null ? m.FromStore!.StoreName : m.LastStation != null ? m.FromStation!.StationName : "Unknown",
To = m.NextUser != null ? m.NextUser!.UserName : m.NextStore != null ? m.NextStore!.StoreName : m.NextStation != null ? m.NextStation!.StationName : "Unknown",
Item = m.Item!.Product!.ProductName,
Quantity = m.Quantity,
Date = m.Date,
Price = m.Item!.ConvertPrice * m.Quantity,
})
.ToList();
var exactMonthStockIn = latestItemMovements
.Where(m => m != null && (m.Action!.ToLower() == "stockin" || m.Action!.ToLower() == "stock in") && m.Date.Month == parsedDate.Month)
.Select(m => new
{
UniqueID = m!.Item!.UniqueID,
From = m!.LastUser != null ? m.FromUser!.UserName : m.LastStore != null ? m.FromStore!.StoreName : m.LastStation != null ? m.FromStation!.StationName : "Unknown",
To = m.NextUser != null ? m.NextUser!.UserName : m.NextStore != null ? m.NextStore!.StoreName : m.NextStation != null ? m.NextStation!.StationName : "Unknown",
Item = m.Item!.Product!.ProductName,
Quantity = m.Quantity,
Date = m.Date,
Price = m.Item!.ConvertPrice * m.Quantity,
})
.ToList();
//select latestItemMovements with the Touser is not null
var latestUserItemMovements = latestItemMovements.Where(m => m != null && m.ItemId != null && m.ToUser > 0 ).ToList();
var latestStationItemMovements = latestItemMovements.Where(m => m != null && m.ItemId != null && m.ToStation > 0).ToList();
@ -264,6 +292,8 @@ namespace PSTW_CentralSystem.Controllers.API
userItemBalance = usersItemMovements,
stationItemBalance = stationItemMovements,
storeItemBalance = storeItemMovements,
exactMonthStockIn = exactMonthStockIn,
exactMonthStockOut = exactMonthStockOut,
};
return Json(report);