diff --git a/Controllers/DashboardController.cs b/Controllers/DashboardController.cs index 8ced7ea..7533d9b 100644 --- a/Controllers/DashboardController.cs +++ b/Controllers/DashboardController.cs @@ -9,5 +9,21 @@ namespace BpsRwApp.Controllers { return View(); } + + [HttpGet] + public IActionResult Table() + { + var data = new[] + { + new { wilayah = "Jakarta Pusat", totalRumah = 79671, totalRumahMemilah = 62392, capaianTarget = 80 }, + new { wilayah = "Jakarta Selatan", totalRumah = 6945, totalRumahMemilah = 93224, capaianTarget = 80 }, + new { wilayah = "Jakarta Barat", totalRumah = 8768, totalRumahMemilah = 55985, capaianTarget = 80 }, + new { wilayah = "Jakarta Timur", totalRumah = 69517, totalRumahMemilah = 13264, capaianTarget = 80 }, + new { wilayah = "Jakarta Utara", totalRumah = 90028, totalRumahMemilah = 53936, capaianTarget = 80 }, + new { wilayah = "Kepulauan Seribu", totalRumah = 98931, totalRumahMemilah = 968, capaianTarget = 80 } + }; + + return Json(new { data }); + } } -} +} \ No newline at end of file diff --git a/Views/Dashboard/Index.cshtml b/Views/Dashboard/Index.cshtml index ab99fd1..b11e638 100644 --- a/Views/Dashboard/Index.cshtml +++ b/Views/Dashboard/Index.cshtml @@ -7,7 +7,7 @@
-

Profile RW 7

+

Admin Pengelola Sampah DLH

+ + download + Download + +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
NoWilayahTotal RumahTotal Rumah MemilahCapaian Target (%)
Subtotal0080
+
+
+ + + + \ No newline at end of file + + // DataTable initialization + $(document).ready(function () { + const table = new DataTable('#tableLaporanRumahMemilah', { + ajax: '@Url.Action("Table", "Dashboard")', + scrollX: true, + autoWidth: false, + initComplete: function () { + $('div.dt-scroll-body thead').css('visibility', 'collapse'); + + // Calculate subtotal + const data = this.api().rows().data(); + let totalRumah = 0; + let totalMemilah = 0; + + data.each(function(row) { + totalRumah += row.totalRumah; + totalMemilah += row.totalRumahMemilah; + }); + + $('#subtotalRumah').text(totalRumah.toLocaleString("id-ID")); + $('#subtotalMemilah').text(totalMemilah.toLocaleString("id-ID")); + }, + columns: [ + { + data: null, + render: (d, t, r, m) => m.row + 1, + orderable: false, + searchable: false + }, + { data: 'wilayah' }, + { + data: 'totalRumah', + render: data => data.toLocaleString("id-ID") + }, + { + data: 'totalRumahMemilah', + render: data => data.toLocaleString("id-ID") + }, + { data: 'capaianTarget' } + ] + }); + + // Filter bulan handler + $('#filterBulanTable').on('change', function() { + const bulan = $(this).val(); + console.log('Filter bulan:', bulan); + }); + }); +