From f8e73bad3a74c37154cb928c520ae327f3035438 Mon Sep 17 00:00:00 2001 From: Mohd Ariff Date: Mon, 23 Feb 2026 16:06:59 +0800 Subject: [PATCH 1/2] Update --- .../Views/Reporting/InventoryReport.cshtml | 65 ++++++++++++++++++- Controllers/API/ReportingAPI.cs | 4 +- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/Areas/Report/Views/Reporting/InventoryReport.cshtml b/Areas/Report/Views/Reporting/InventoryReport.cshtml index 040efdd..d22da9d 100644 --- a/Areas/Report/Views/Reporting/InventoryReport.cshtml +++ b/Areas/Report/Views/Reporting/InventoryReport.cshtml @@ -78,6 +78,58 @@ +
+
+

User Report

+
+
+
+
+
+
+

Department

+ + +
+
+
+
+
+

Date filter

+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+

Statistic

+

Total Number of Item Registered: {{ reportData.itemCountRegistered }}

+

Total Number of Item Still in Stock: {{ reportData.itemCountStillInStock }}

+
+
+

Item Registered

+

This Month: {{ reportData.itemCountRegisteredThisMonth }}

+

Last Month: {{ reportData.itemCountRegisteredLastMonth }}

+
+
+

Item Stock Out

+

This Month: {{ reportData.itemCountStockOutThisMonth }}

+

Last Month: {{ reportData.itemCountStockOutLastMonth }}

+
+
+
+
+
@section Scripts { @{ @@ -112,13 +164,14 @@ selectedMonth: [], selectedDepartment: [], selectedItem: [], - selectedCategory: [] + selectedCategory: [], + usersInfo: [], + submitBody: null, } }, mounted() { this.fetchUser(); this.fetchProductList(); - this.fetchCurrentReport(); this.fetchDepartmentsCompaniesList(); }, watch: { @@ -131,6 +184,14 @@ } }, methods: { + async generateReport(){ + this.submitBody = { + selectedMonth: this.selectedMonth, + selectedDepartment: this.selectedDepartment + } + console.log(this.submitBody); + // this.fetchCurrentReport(); + }, async fetchCurrentReport(){ try { const response = await fetch(`/ReportingAPI/GetMonthlyReport/`, { diff --git a/Controllers/API/ReportingAPI.cs b/Controllers/API/ReportingAPI.cs index bcfa336..96521c1 100644 --- a/Controllers/API/ReportingAPI.cs +++ b/Controllers/API/ReportingAPI.cs @@ -209,8 +209,8 @@ namespace PSTW_CentralSystem.Controllers.API .ToListAsync(); var latestItemMovements = await _centralDbContext.ItemMovements - //.Include(m => m.Item) - //.Include(m => m.Item!.Product) + .Include(m => m.Item) + .Include(m => m.Item!.Product) .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)) .GroupBy(m => m.ItemId) From 8d3385f6736674262e260b387eeb31b25a3e95c1 Mon Sep 17 00:00:00 2001 From: Mohd Ariff Date: Fri, 27 Feb 2026 17:40:32 +0800 Subject: [PATCH 2/2] Update --- .../Views/Reporting/InventoryReport.cshtml | 104 +++++++++++------- Controllers/API/ReportingAPI.cs | 21 ++-- 2 files changed, 76 insertions(+), 49 deletions(-) diff --git a/Areas/Report/Views/Reporting/InventoryReport.cshtml b/Areas/Report/Views/Reporting/InventoryReport.cshtml index d22da9d..53b50ee 100644 --- a/Areas/Report/Views/Reporting/InventoryReport.cshtml +++ b/Areas/Report/Views/Reporting/InventoryReport.cshtml @@ -16,15 +16,6 @@
-
-
-

Department

- - -
-
-

Category

@@ -41,13 +32,6 @@
-
-
-

Date filter

- -
-
-
@@ -88,17 +72,24 @@

Department

- + -
+

Date filter

- -
+ +
+
+
+
+
+

Position Filter

+ +
@@ -111,20 +102,13 @@
-
-

Statistic

-

Total Number of Item Registered: {{ reportData.itemCountRegistered }}

-

Total Number of Item Still in Stock: {{ reportData.itemCountStillInStock }}

-
-
-

Item Registered

-

This Month: {{ reportData.itemCountRegisteredThisMonth }}

-

Last Month: {{ reportData.itemCountRegisteredLastMonth }}

-
-
-

Item Stock Out

-

This Month: {{ reportData.itemCountStockOutThisMonth }}

-

Last Month: {{ reportData.itemCountStockOutLastMonth }}

+
+
+

User List

+ +
+ {{ selectedUser }} +
@@ -160,13 +144,22 @@ productList: {}, categoryList:['Asset', 'Part', 'Disposable'], monthList: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], + positionList: [ + { positionId: 1, positionName: 'User' }, + { positionId: 2, positionName: 'Station' }, + { positionId: 3, positionName: 'Store' } + ], filteredProduct: [], - selectedMonth: [], + selectedMonth: null, selectedDepartment: [], + selectedSingleDepartment: null, selectedItem: [], selectedCategory: [], + selectedPosition: [], usersInfo: [], submitBody: null, + formResponse: null, + selectedUser: [], } }, mounted() { @@ -185,21 +178,48 @@ }, methods: { async generateReport(){ - this.submitBody = { - selectedMonth: this.selectedMonth, - selectedDepartment: this.selectedDepartment + if(this.selectedMonth == null || this.selectedSingleDepartment.length == 0 || this.selectedPosition.length == 0) + { + var msg = []; + if(this.selectedMonth == null) + { + msg.push("Date"); + } + if(this.selectedSingleDepartment.length == 0) + { + msg.push("Department"); + } + if(this.selectedPosition.length == 0) + { + msg.push("Position"); + } + alert(msg.length > 1 ? msg.join(" & ") + " cannot be empty" : msg[0] + " cannot be empty"); + } + else{ + this.submitBody = { + formDate: new Date(this.selectedMonth.year, this.selectedMonth.month + 1, 0, 23, 59, 59).toISOString().slice(0, 19), + // selectedCategory: this.selectedCategory, + deptId: this.selectedSingleDepartment.departmentCode, + toUser: this.selectedPosition.positionId == 1 ? 1 : 0, + toStation: this.selectedPosition.positionId == 2 ? 1 : 0, + toStore: this.selectedPosition.positionId == 3 ? 1 : 0, + } + this.fetchCurrentReport(); } - console.log(this.submitBody); - // this.fetchCurrentReport(); }, async fetchCurrentReport(){ try { const response = await fetch(`/ReportingAPI/GetMonthlyReport/`, { + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(this.submitBody), method: 'POST', }); if (response.ok) { const data = await response.json(); - console.log(data); + this.formResponse = data + console.log(this.formResponse); } else { console.error(`Failed to fetch user: ${response.statusText}`); diff --git a/Controllers/API/ReportingAPI.cs b/Controllers/API/ReportingAPI.cs index 96521c1..72a6b7f 100644 --- a/Controllers/API/ReportingAPI.cs +++ b/Controllers/API/ReportingAPI.cs @@ -35,11 +35,11 @@ namespace PSTW_CentralSystem.Controllers.API public class ReportQuery { - string? FormDate { get; set; } - string? DeptId { get; set; } - int ToUser { get; set; } - int ToStation { get; set; } - int ToStore { get; set; } + public string? FormDate { get; set; } + public string? DeptId { get; set; } + public int ToUser { get; set; } + public int ToStation { get; set; } + public int ToStore { get; set; } } #region ItemReport @@ -135,10 +135,15 @@ namespace PSTW_CentralSystem.Controllers.API #region Monthly Report [HttpPost("GetMonthlyReport")] - public async Task GetMonthlyReport([FromBody] string FormDate = "2026/1/31", string DeptId = "PA", int ToUser = 1, int ToStation = 0, int ToStore = 0) + public async Task GetMonthlyReport([FromBody] ReportQuery reportQuery) { try { + string FormDate = reportQuery.FormDate!; + string DeptId = reportQuery.DeptId!; + int ToUser = reportQuery.ToUser; + int ToStation = reportQuery.ToStation; + int ToStore = reportQuery.ToStore; var currentProductBalance = new List(); var result = await _centralDbContext.Products .Select(p => new { p.ProductName, p.QuantityJSON }) @@ -233,8 +238,10 @@ namespace PSTW_CentralSystem.Controllers.API ItemId = m.ItemId, ItemName = m.Item!.Product!.ProductName, Quantity = m.Quantity, + ItemPrice = m.Item!.ConvertPrice, }) - .ToList() + .ToList(), + TotalItemPrice = latestItemMovements.Where(m => m.ToUser == u.Id).Sum(m => m!.Item!.ConvertPrice * m.Quantity), }) .Where(u => u.Items.Count > 0).ToList();