bank-sampah/Views/Main/ReduksiSampahDinas/Index.cshtml

93 lines
3.1 KiB
Plaintext

@{
ViewData["Title"] = "Reduksi Sampah Dinas";
}
<div class="flex flex-col gap-2 md:flex-row md:justify-between md:gap-0 items-center">
<div class="prose">
<span class="text-xl font-semibold text-black">
Reduksi Sampah Dinas
</span>
</div>
<div class="flex gap-2 items-center">
<select class="select rounded-full">
<option disabled selected>Pilih Tahun</option>
<option>2025</option>
<option>2024</option>
<option>2023</option>
<option>2022</option>
<option>2021</option>
<option>2020</option>
</select>
</div>
</div>
<div class="h-6"></div>
<div class="card bg-white shadow-sm">
<div class="card-body p-2">
<div class="w-full overflow-x-auto">
<table class="table-zebra table w-full" id="example">
<!-- head -->
<thead>
<tr>
<th>No</th>
<th>Periode</th>
<th>Nama Lokasi</th>
<th>Alamat</th>
<th>Berat Maggot(Kg)</th>
<th>Berat Komposting(Kg)</th>
<th>Berat Bank Sampah(Kg)</th>
<th>Total Reduksi(Kg)</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
@section Scripts {
<script type="text/javascript">
var table;
$(document).ready(function () {
table = new DataTable('#example', {
ajax: '/Main/ReduksiSampahDinas/Table',
scrollX: true,
autoWidth: false,
initComplete: function () {
$('div.dt-scroll-body thead').css('visibility', 'collapse');
},
columns: [
{ data: null, render: (d, t, r, m) => m.row + 1, orderable: false, searchable: false },
{ data: 'periode_bulan' },
{ data: 'nama_lokasi' },
{ data: 'alamat' },
{ data: 'berat_maggot' },
{ data: 'berat_komposting' },
{ data: 'berat_bank_sampah' },
{
data: null,
render: function (data, type, row) {
let maggot = parseFloat(row.berat_maggot) || 0;
let komposting = parseFloat(row.berat_komposting) || 0;
let bankSampah = parseFloat(row.berat_bank_sampah) || 0;
let total = maggot + komposting + bankSampah;
return total;
}
},
{ data: 'aksi', orderable: false, searchable: false },
]
});
$('#example').on('click', '.btn-history', function (e) {
e.preventDefault();
modal_history.showModal();
});
});
</script>
}