diff --git a/Controllers/Master/SubKategoriSampahController.cs b/Controllers/Master/SubKategoriSampahController.cs index 7b20d83..253b609 100644 --- a/Controllers/Master/SubKategoriSampahController.cs +++ b/Controllers/Master/SubKategoriSampahController.cs @@ -16,49 +16,58 @@ namespace BankSampahApp.Controllers.Master var data = new[] { new { - nama = "Duplek", + nama = "Kertas", kategori_sampah = "Kertas", jenis_sampah = "Anorganik", aksi = "
" + - "" + - "" + - "
", + "" + + "" + + "", }, new { nama = "Kardus", - kategori_sampah = "Kertas", + kategori_sampah = "Kardus", jenis_sampah = "Anorganik", aksi = "
" + - "" + - "" + - "
", + "" + + "" + + "", }, new { - nama = "Kertas HVS/Putihan", - kategori_sampah = "Kertas", + nama = "Plastik", + kategori_sampah = "Plastik", jenis_sampah = "Anorganik", aksi = "
" + - "" + - "" + - "
", + "" + + "" + + "", }, new { - nama = "Buku", - kategori_sampah = "Kertas", + nama = "Lain-lain", + kategori_sampah = "Lain-lain", jenis_sampah = "Anorganik", aksi = "
" + - "" + - "" + - "
", + "" + + "" + + "", }, new { - nama = "Majalah", - kategori_sampah = "Kertas", - jenis_sampah = "Anorganik", + nama = "Sisa Makanan", + kategori_sampah = "Sisa Makanan", + jenis_sampah = "Organik", aksi = "
" + - "" + - "" + - "
", + "" + + "" + + "", + }, + new { + nama = "Baterai Bekas", + kategori_sampah = "Baterai Bekas", + jenis_sampah = "B3 Sampah Rumah Tangga", + aksi = "
" + + "" + + "" + + "
", }, }; diff --git a/Views/Master/SubKategoriSampah/Index.cshtml b/Views/Master/SubKategoriSampah/Index.cshtml index 2069cc1..40164b1 100644 --- a/Views/Master/SubKategoriSampah/Index.cshtml +++ b/Views/Master/SubKategoriSampah/Index.cshtml @@ -10,7 +10,7 @@
- @@ -24,6 +24,19 @@
+ +
+
+ + Kategori Sampah + * + + +
+
+
@@ -62,7 +75,9 @@ No - Nama Sub Kategori Sampah + Nama Sub Kategori Sampah + Kategori + Jenis Aksi @@ -88,6 +103,8 @@ columns: [ { data: null, render: (d, t, r, m) => m.row + 1, orderable: false, searchable: false }, { data: 'nama' }, + { data: 'kategori_sampah' }, + { data: 'jenis_sampah' }, { data: 'aksi' }, ] }); @@ -147,6 +164,36 @@ }); }); + function openModal() { + modal_tambah.showModal(); + + // load dropdown setiap modal dibuka + loadKategoriSampah(); + } + + function loadKategoriSampah() { + $.ajax({ + url: '/Master/KategoriSampah/table', // Ganti sesuai endpoint kamu + method: 'GET', + dataType: 'json', + success: function (response) { + // Buat HTML option dengan map + let options = response.data + .map(item => ``) + .join(""); + + // Masukkan ke dropdown + $("#kategori_sampah").html(` + + ${options} + `); + }, + error: function () { + console.error('Gagal memuat data jenis sampah.'); + } + }); + } + function closeModal() { // Reset form $('#formTambah')[0].reset(); @@ -155,6 +202,7 @@ // Close modal modal_tambah.close(); + loadKategoriSampah(); } function submitForm(e) {