This commit is contained in:
MOHD ARIFF 2026-02-23 16:06:59 +08:00
parent 2735cfdf99
commit f8e73bad3a
2 changed files with 65 additions and 4 deletions

View File

@ -78,6 +78,58 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row card">
<div class="card-header">
<h3 class="card-title">User Report</h3>
</div>
<div class="card-body">
<div v-if="reportData">
<div class="row justify-content-center">
<div class="col-3">
<div class="row col-10">
<h4>Department</h4>
<multiselect v-model="selectedDepartment" :options="compDeptList" :multiple="true" group-values="departments" group-label="companyName"
:group-select="true" placeholder="Seach Department" track-by="departmentId" label="departmentName">
</multiselect>
<div class=""><button class="btn btn-danger" v-on:click="selectedDepartment = []">Clear</button></div>
</div>
</div>
<div class="col-3">
<div class="row col-10">
<h4>Date filter</h4>
<vue-date-picker v-model="selectedMonth" month-picker></vue-date-picker>
<div class=""><button class="btn btn-danger" v-on:click="selectedMonth = []">Clear</button></div>
</div>
</div>
<div class="col-12">
<button class="btn btn-primary" v-on:click="generateReport">Generate Report</button>
</div>
</div>
</div>
</div>
<hr />
<div class="card-body">
<div v-if="reportData">
<div class="row justify-content-center">
<div class="col-3">
<h4>Statistic</h4>
<p>Total Number of Item Registered: {{ reportData.itemCountRegistered }}</p>
<p>Total Number of Item Still in Stock: {{ reportData.itemCountStillInStock }}</p>
</div>
<div class="col-3">
<h4>Item Registered </h4>
<p>This Month: {{ reportData.itemCountRegisteredThisMonth }}</p>
<p>Last Month: {{ reportData.itemCountRegisteredLastMonth }}</p>
</div>
<div class="col-3">
<h4>Item Stock Out </h4>
<p>This Month: {{ reportData.itemCountStockOutThisMonth }}</p>
<p>Last Month: {{ reportData.itemCountStockOutLastMonth }}</p>
</div>
</div>
</div>
</div>
</div>
</div> </div>
@section Scripts { @section Scripts {
@{ @{
@ -112,13 +164,14 @@
selectedMonth: [], selectedMonth: [],
selectedDepartment: [], selectedDepartment: [],
selectedItem: [], selectedItem: [],
selectedCategory: [] selectedCategory: [],
usersInfo: [],
submitBody: null,
} }
}, },
mounted() { mounted() {
this.fetchUser(); this.fetchUser();
this.fetchProductList(); this.fetchProductList();
this.fetchCurrentReport();
this.fetchDepartmentsCompaniesList(); this.fetchDepartmentsCompaniesList();
}, },
watch: { watch: {
@ -131,6 +184,14 @@
} }
}, },
methods: { methods: {
async generateReport(){
this.submitBody = {
selectedMonth: this.selectedMonth,
selectedDepartment: this.selectedDepartment
}
console.log(this.submitBody);
// this.fetchCurrentReport();
},
async fetchCurrentReport(){ async fetchCurrentReport(){
try { try {
const response = await fetch(`/ReportingAPI/GetMonthlyReport/`, { const response = await fetch(`/ReportingAPI/GetMonthlyReport/`, {

View File

@ -209,8 +209,8 @@ namespace PSTW_CentralSystem.Controllers.API
.ToListAsync(); .ToListAsync();
var latestItemMovements = await _centralDbContext.ItemMovements var latestItemMovements = await _centralDbContext.ItemMovements
//.Include(m => m.Item) .Include(m => m.Item)
//.Include(m => m.Item!.Product) .Include(m => m.Item!.Product)
.Include(m => m.NextUser) .Include(m => m.NextUser)
.Where(m => m.ItemId != null && (ToUser > 0 ? m.ToUser != null : m.ToUser > 0) && (ToStation > 0 ? m.ToStation != null : m.ToStation > 0) && (ToStore > 0 ? m.ToStore != null : m.ToStore > 0)) .Where(m => m.ItemId != null && (ToUser > 0 ? m.ToUser != null : m.ToUser > 0) && (ToStation > 0 ? m.ToStation != null : m.ToStation > 0) && (ToStore > 0 ? m.ToStore != null : m.ToStore > 0))
.GroupBy(m => m.ItemId) .GroupBy(m => m.ItemId)