diff --git a/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml b/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml index f8639fd..1db746f 100644 --- a/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml +++ b/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml @@ -617,6 +617,18 @@ "title": "Part Number", "data": "partNumber", }, + { + "title": "Location", + "data": "currentUser", + "render": function (data, type, full, meta) { + currentUser = data ?? null; + currentStore = full.currentStore ?? 'N/A'; + currentStation = full.currentStation ?? 'N/A'; + return `User: ${currentUser}
+ Store: ${currentStore}
+ Station: ${currentStation}` + } + }, { "title": "Category", "data": "category", @@ -659,18 +671,6 @@ return data ? new Date(data).toLocaleString() : ''; // Format date for display } }, - { - "title": "Location", - "data": "currentUser", - "render": function (data, type, full, meta) { - currentUser = data ?? null; - currentStore = full.currentStore ?? 'N/A'; - currentStation = full.currentStation ?? 'N/A'; - return `User: ${currentUser}
- Store: ${currentStore}
- Station: ${currentStation}` - } - }, { "title": "Edit", "data": "itemID", diff --git a/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml b/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml index 736faed..3f39ef1 100644 --- a/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml +++ b/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml @@ -1073,16 +1073,15 @@ this.maxQuantity = null; } - console.log('last store' + this.thisItem.lastStore); this.itemlateststatus = this.thisItem.latestStatus ? this.thisItem.latestStatus : this.thisItem.toOther; - this.itemassignedtouser = (this.thisItem.toUser === this.currentUser.id || this.thisItem.lastUser === this.currentUser.id) && this.thisItem.lastStore === this.currentUser.store ? true : false; - - console.log(this.thisItem.lastStore); - console.log(this.thisItem.lastStore == this.currentUser.store ? true : false); - console.log(this.thisItem.toUser == this.currentUser.id ? true : false); - console.log(this.thisItem.lastUser == this.currentUser.id ? true : false); - console.log(((this.thisItem.toUser == this.currentUser.id) || (this.thisItem.lastUser == this.currentUser.id)) ? true : false); - console.log('currentuser store' + this.currentUser.store); + this.itemassignedtouser = ( + (this.thisItem.toStore === this.currentUser.store || this.thisItem.lastStore === this.currentUser.store) + && this.currentUser.store != null + ); + // Debugging logs to help you verify in the browser console + console.log('Item Store ID:', this.thisItem.toStore); + console.log('User Master Store ID:', this.currentUser.store); + console.log('Is User Authorized Master for this item?', this.itemassignedtouser); } else { // If the response is not OK (e.g., 404 Not Found) diff --git a/Areas/Report/Views/Reporting/InventoryReportManagement.cshtml b/Areas/Report/Views/Reporting/InventoryReportManagement.cshtml index bbaa9cb..23a93a4 100644 --- a/Areas/Report/Views/Reporting/InventoryReportManagement.cshtml +++ b/Areas/Report/Views/Reporting/InventoryReportManagement.cshtml @@ -15,19 +15,23 @@
-
-
-

Department

+
+
+
+

Department

+
-
-
-

Category

- - +
+
+
+

Category

+ + +
diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs index 875eeff..511896a 100644 --- a/Controllers/API/Inventory/InvMainAPI.cs +++ b/Controllers/API/Inventory/InvMainAPI.cs @@ -11,10 +11,11 @@ using PSTW_CentralSystem.DBContext; using PSTW_CentralSystem.Models; using System.ComponentModel.Design; using System.Data; +using System.Data.SqlClient; using System.Diagnostics; using System.Reflection; +using System.Security.Claims; using static System.Collections.Specialized.BitVector32; -using System.Data.SqlClient; namespace PSTW_CentralSystem.Controllers.API.Inventory { @@ -1513,8 +1514,31 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory [HttpGet("ItemRequestList")] public async Task ItemRequestList() { + // 1. Get the current logged-in User's ID (this comes as a string from Claims) + var userIdString = User.FindFirstValue(ClaimTypes.NameIdentifier); + + // 2. Parse the string to an int + if (!int.TryParse(userIdString, out int currentUserId)) + { + return Unauthorized("Invalid User ID format."); + } + + // 3. Now the comparison will work because both are 'int' + var masterUser = await _centralDbContext.Users + .FirstOrDefaultAsync(u => u.Id == currentUserId); + + if (masterUser == null) return Unauthorized(); + + var masterDeptId = masterUser.departmentId; + + // 4. Fetch requests where the Requester belongs to the same department + var itemRequestList = await _centralDbContext.Requests + .Include(i => i.Product) + .Include(i => i.User) + .Include(i => i.Station) + .Where(i => i.User.departmentId == masterDeptId) + .ToListAsync(); - var itemRequestList = await _centralDbContext.Requests.Include(i => i.Product).Include(i => i.User).Include(i => i.Station).ToListAsync(); return Json(itemRequestList.Select(i => new { i.requestID, @@ -1534,10 +1558,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory i.remarkMasterInv, i.remarkUser, i.assignStoreItem, - i.fromStoreItem, - + i.fromStoreItem })); - } [HttpPost("ApproveRequest/{id}")] diff --git a/wwwroot/Media/Inventory/itemmovement/6_95459b73-31a0-488a-908f-c1fb30f58d8b6_Request.pdf b/wwwroot/Media/Inventory/itemmovement/6_95459b73-31a0-488a-908f-c1fb30f58d8b6_Request.pdf new file mode 100644 index 0000000..171d1b9 --- /dev/null +++ b/wwwroot/Media/Inventory/itemmovement/6_95459b73-31a0-488a-908f-c1fb30f58d8b6_Request.pdf @@ -0,0 +1,74 @@ +%PDF-1.4 +%東京 ReportLab Generated PDF document http://www.reportlab.com +1 0 obj +<< +/F1 2 0 R /F2 3 0 R +>> +endobj +2 0 obj +<< +/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font +>> +endobj +3 0 obj +<< +/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font +>> +endobj +4 0 obj +<< +/Contents 8 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 7 0 R /Resources << +/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] +>> /Rotate 0 /Trans << + +>> + /Type /Page +>> +endobj +5 0 obj +<< +/PageMode /UseNone /Pages 7 0 R /Type /Catalog +>> +endobj +6 0 obj +<< +/Author (\(anonymous\)) /CreationDate (D:20260202150517+00'00') /Creator (\(unspecified\)) /Keywords () /ModDate (D:20260202150517+00'00') /Producer (ReportLab PDF Library - www.reportlab.com) + /Subject (\(unspecified\)) /Title (\(anonymous\)) /Trapped /False +>> +endobj +7 0 obj +<< +/Count 1 /Kids [ 4 0 R ] /Type /Pages +>> +endobj +8 0 obj +<< +/Filter [ /ASCII85Decode /FlateDecode ] /Length 160 +>> +stream +Gaqcn0a`P0&4HCY`KWq:?YBC/f/@$:1m5P'P!Hf,\UT`A7$)t:hTd(7Nc;\l%,;iQSY3i,?qCP$5k"7YDP+&)/PKcI73b(2K&9e,b?Yq'3E-@>U/G8bm$cGbCr(P:anr!.i?.guf-?3q+`a+'][%&hq#_LE-9V~>endstream +endobj +xref +0 9 +0000000000 65535 f +0000000073 00000 n +0000000114 00000 n +0000000221 00000 n +0000000333 00000 n +0000000536 00000 n +0000000604 00000 n +0000000887 00000 n +0000000946 00000 n +trailer +<< +/ID +[<81e58f83a69adfcd325d786fea9424ec><81e58f83a69adfcd325d786fea9424ec>] +% ReportLab generated PDF document -- digest (http://www.reportlab.com) + +/Info 6 0 R +/Root 5 0 R +/Size 9 +>> +startxref +1196 +%%EOF diff --git a/wwwroot/Media/Inventory/itemmovement/6_eabe95d9-0825-45c1-8553-d500a9bcb3dc6_Request.pdf b/wwwroot/Media/Inventory/itemmovement/6_eabe95d9-0825-45c1-8553-d500a9bcb3dc6_Request.pdf new file mode 100644 index 0000000..171d1b9 --- /dev/null +++ b/wwwroot/Media/Inventory/itemmovement/6_eabe95d9-0825-45c1-8553-d500a9bcb3dc6_Request.pdf @@ -0,0 +1,74 @@ +%PDF-1.4 +%東京 ReportLab Generated PDF document http://www.reportlab.com +1 0 obj +<< +/F1 2 0 R /F2 3 0 R +>> +endobj +2 0 obj +<< +/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font +>> +endobj +3 0 obj +<< +/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font +>> +endobj +4 0 obj +<< +/Contents 8 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 7 0 R /Resources << +/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] +>> /Rotate 0 /Trans << + +>> + /Type /Page +>> +endobj +5 0 obj +<< +/PageMode /UseNone /Pages 7 0 R /Type /Catalog +>> +endobj +6 0 obj +<< +/Author (\(anonymous\)) /CreationDate (D:20260202150517+00'00') /Creator (\(unspecified\)) /Keywords () /ModDate (D:20260202150517+00'00') /Producer (ReportLab PDF Library - www.reportlab.com) + /Subject (\(unspecified\)) /Title (\(anonymous\)) /Trapped /False +>> +endobj +7 0 obj +<< +/Count 1 /Kids [ 4 0 R ] /Type /Pages +>> +endobj +8 0 obj +<< +/Filter [ /ASCII85Decode /FlateDecode ] /Length 160 +>> +stream +Gaqcn0a`P0&4HCY`KWq:?YBC/f/@$:1m5P'P!Hf,\UT`A7$)t:hTd(7Nc;\l%,;iQSY3i,?qCP$5k"7YDP+&)/PKcI73b(2K&9e,b?Yq'3E-@>U/G8bm$cGbCr(P:anr!.i?.guf-?3q+`a+'][%&hq#_LE-9V~>endstream +endobj +xref +0 9 +0000000000 65535 f +0000000073 00000 n +0000000114 00000 n +0000000221 00000 n +0000000333 00000 n +0000000536 00000 n +0000000604 00000 n +0000000887 00000 n +0000000946 00000 n +trailer +<< +/ID +[<81e58f83a69adfcd325d786fea9424ec><81e58f83a69adfcd325d786fea9424ec>] +% ReportLab generated PDF document -- digest (http://www.reportlab.com) + +/Info 6 0 R +/Root 5 0 R +/Size 9 +>> +startxref +1196 +%%EOF diff --git a/wwwroot/Media/Inventory/itemmovement/6_f3e04d6d-85c9-4c7f-b585-9ba4f996a56c6_Request.jpg b/wwwroot/Media/Inventory/itemmovement/6_f3e04d6d-85c9-4c7f-b585-9ba4f996a56c6_Request.jpg new file mode 100644 index 0000000..83c1f35 Binary files /dev/null and b/wwwroot/Media/Inventory/itemmovement/6_f3e04d6d-85c9-4c7f-b585-9ba4f996a56c6_Request.jpg differ diff --git a/wwwroot/Media/Inventory/itemmovement/core1user 1405-DF(T9LSUO82) Station.jpg b/wwwroot/Media/Inventory/itemmovement/core1user 1405-DF(T9LSUO82) Station.jpg new file mode 100644 index 0000000..83c1f35 Binary files /dev/null and b/wwwroot/Media/Inventory/itemmovement/core1user 1405-DF(T9LSUO82) Station.jpg differ diff --git a/wwwroot/Media/Inventory/itemmovement/core1user 1405-DFReturn.pdf b/wwwroot/Media/Inventory/itemmovement/core1user 1405-DFReturn.pdf new file mode 100644 index 0000000..171d1b9 --- /dev/null +++ b/wwwroot/Media/Inventory/itemmovement/core1user 1405-DFReturn.pdf @@ -0,0 +1,74 @@ +%PDF-1.4 +%東京 ReportLab Generated PDF document http://www.reportlab.com +1 0 obj +<< +/F1 2 0 R /F2 3 0 R +>> +endobj +2 0 obj +<< +/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font +>> +endobj +3 0 obj +<< +/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font +>> +endobj +4 0 obj +<< +/Contents 8 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 7 0 R /Resources << +/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] +>> /Rotate 0 /Trans << + +>> + /Type /Page +>> +endobj +5 0 obj +<< +/PageMode /UseNone /Pages 7 0 R /Type /Catalog +>> +endobj +6 0 obj +<< +/Author (\(anonymous\)) /CreationDate (D:20260202150517+00'00') /Creator (\(unspecified\)) /Keywords () /ModDate (D:20260202150517+00'00') /Producer (ReportLab PDF Library - www.reportlab.com) + /Subject (\(unspecified\)) /Title (\(anonymous\)) /Trapped /False +>> +endobj +7 0 obj +<< +/Count 1 /Kids [ 4 0 R ] /Type /Pages +>> +endobj +8 0 obj +<< +/Filter [ /ASCII85Decode /FlateDecode ] /Length 160 +>> +stream +Gaqcn0a`P0&4HCY`KWq:?YBC/f/@$:1m5P'P!Hf,\UT`A7$)t:hTd(7Nc;\l%,;iQSY3i,?qCP$5k"7YDP+&)/PKcI73b(2K&9e,b?Yq'3E-@>U/G8bm$cGbCr(P:anr!.i?.guf-?3q+`a+'][%&hq#_LE-9V~>endstream +endobj +xref +0 9 +0000000000 65535 f +0000000073 00000 n +0000000114 00000 n +0000000221 00000 n +0000000333 00000 n +0000000536 00000 n +0000000604 00000 n +0000000887 00000 n +0000000946 00000 n +trailer +<< +/ID +[<81e58f83a69adfcd325d786fea9424ec><81e58f83a69adfcd325d786fea9424ec>] +% ReportLab generated PDF document -- digest (http://www.reportlab.com) + +/Info 6 0 R +/Root 5 0 R +/Size 9 +>> +startxref +1196 +%%EOF diff --git a/wwwroot/Media/Inventory/itemmovement/core1user_1405-DF_CKFVE8NX_Return.pdf b/wwwroot/Media/Inventory/itemmovement/core1user_1405-DF_CKFVE8NX_Return.pdf new file mode 100644 index 0000000..171d1b9 --- /dev/null +++ b/wwwroot/Media/Inventory/itemmovement/core1user_1405-DF_CKFVE8NX_Return.pdf @@ -0,0 +1,74 @@ +%PDF-1.4 +%東京 ReportLab Generated PDF document http://www.reportlab.com +1 0 obj +<< +/F1 2 0 R /F2 3 0 R +>> +endobj +2 0 obj +<< +/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font +>> +endobj +3 0 obj +<< +/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font +>> +endobj +4 0 obj +<< +/Contents 8 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 7 0 R /Resources << +/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] +>> /Rotate 0 /Trans << + +>> + /Type /Page +>> +endobj +5 0 obj +<< +/PageMode /UseNone /Pages 7 0 R /Type /Catalog +>> +endobj +6 0 obj +<< +/Author (\(anonymous\)) /CreationDate (D:20260202150517+00'00') /Creator (\(unspecified\)) /Keywords () /ModDate (D:20260202150517+00'00') /Producer (ReportLab PDF Library - www.reportlab.com) + /Subject (\(unspecified\)) /Title (\(anonymous\)) /Trapped /False +>> +endobj +7 0 obj +<< +/Count 1 /Kids [ 4 0 R ] /Type /Pages +>> +endobj +8 0 obj +<< +/Filter [ /ASCII85Decode /FlateDecode ] /Length 160 +>> +stream +Gaqcn0a`P0&4HCY`KWq:?YBC/f/@$:1m5P'P!Hf,\UT`A7$)t:hTd(7Nc;\l%,;iQSY3i,?qCP$5k"7YDP+&)/PKcI73b(2K&9e,b?Yq'3E-@>U/G8bm$cGbCr(P:anr!.i?.guf-?3q+`a+'][%&hq#_LE-9V~>endstream +endobj +xref +0 9 +0000000000 65535 f +0000000073 00000 n +0000000114 00000 n +0000000221 00000 n +0000000333 00000 n +0000000536 00000 n +0000000604 00000 n +0000000887 00000 n +0000000946 00000 n +trailer +<< +/ID +[<81e58f83a69adfcd325d786fea9424ec><81e58f83a69adfcd325d786fea9424ec>] +% ReportLab generated PDF document -- digest (http://www.reportlab.com) + +/Info 6 0 R +/Root 5 0 R +/Size 9 +>> +startxref +1196 +%%EOF