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

202 lines
8.3 KiB
Plaintext

@{
ViewData["Title"] = "Reduksi Sampah";
}
<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
</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>
<button type="button" class="btn btn-sm bg-bank-sampah-primary-500 rounded-full text-white" onclick="modal_tambah.showModal()"><i class="ph ph-plus"></i>Tambah</button>
</div>
</div>
<!-- Modal Tambah/Edit Data -->
<dialog id="modal_tambah" class="modal modal-bottom sm:modal-middle">
<div class="modal-box w-full max-w-2xl p-6 bg-white rounded-2xl">
<h3 id="modal_title" class="text-gray-900 text-xl font-semibold font-['Plus_Jakarta_Sans'] leading-8 mb-8">Tambah Reduksi Sampah</h3>
<form id="formTambah" onsubmit="submitForm(event)">
<input type="hidden" id="edit_mode" value="false">
<div class="flex flex-col gap-6">
<!-- Fiel Jenis Lokasi -->
<div class="flex flex-col">
<fieldset class="fieldset">
<legend class="fieldset-legend">
Jenis Lokasi
<span class="text-red-500">*</span>
</legend>
<select id="jenis_lokasi" class="select w-full" required>
<option value="" disabled selected>Pilih salah satu</option>
<option>Komposting</option>
<option>Maggot</option>
</select>
</fieldset>
</div>
<div id="formDetail" class="hidden flex flex-col gap-6">
<!-- Field Lokasi -->
<div class="flex flex-col">
<fieldset class="fieldset">
<legend class="fieldset-legend">
Lokasi<span class="text-red-500">*</span>
</legend>
<select id="lokasi" class="select w-full" required>
<option value="" disabled selected>Pilih salah satu</option>
</select>
</fieldset>
</div>
<!-- Field alamat -->
<div class="flex flex-col">
<fieldset class="fieldset">
<legend class="fieldset-legend">
Alamat
</legend>
<textarea id="alamat" rows="4" readonly class="textarea textarea-bordered w-full"></textarea>
</fieldset>
</div>
<!-- Field Bukti Kegiatan -->
<div class="flex flex-col">
<fieldset class="fieldset">
<legend class="fieldset-legend">
Bukti Kegiatan
<span class="text-red-500">*</span>
</legend>
<input type="file" class="file-input w-full" />
<label class="label">Ukuran Maksimal 5MB</label>
</fieldset>
</div>
<!-- Field Keterangan -->
<div class="flex flex-col">
<fieldset class="fieldset">
<legend class="fieldset-legend">
Keterangan Kegiatan<span class="text-red-500">*</span>
</legend>
<textarea id="keterangan_kegiatan" rows="4" required class="textarea textarea-bordered w-full"></textarea>
</fieldset>
</div>
<!-- Field Tanggal Pelaksanaan Kegiatan -->
<div class="flex flex-col">
<fieldset class="fieldset">
<legend class="fieldset-legend">
Tanggal Pelaksanaan Kegiatan
<span class="text-red-500">*</span>
</legend>
<input type="date" id="tgl_pelaksanaan_kegiatan" class="input w-full" required />
</fieldset>
</div>
<!-- Pelaksana kegiatan -->
<div class="flex flex-col">
<fieldset class="fieldset">
<legend class="fieldset-legend">
Pelaksana Kegiatan<span class="text-red-500">*</span>
</legend>
<input type="text" id="preview" class="input w-full" placeholder="Preview Text Artikel" required />
</fieldset>
</div>
</div>
<!-- Buttons -->
<div class="flex flex-col sm:flex-row gap-3 justify-end">
<button type="button" class="px-8 py-2.5 bg-white rounded-full outline outline-1 -outline-offset-1 outline-gray-300 text-slate-800 text-base font-semibold font-['Plus_Jakarta_Sans'] leading-6 hover:bg-gray-50 w-full sm:w-auto" onclick="closeModal()">
Batal
</button>
<button type="submit" class="px-8 py-2.5 bg-green-800 rounded-full text-white text-base font-semibold font-['Plus_Jakarta_Sans'] leading-6 hover:bg-green-900 w-full sm:w-auto">
Simpan
</button>
</div>
</div>
</form>
</div>
<form method="dialog" class="modal-backdrop">
<button>close</button>
</form>
</dialog>
<!-- /modal tambah/edit -->
<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>Nama Lokasi</th>
<th>Alamat</th>
<th>Jenis Lokasi</th>
<th>Berat(Kg)</th>
<th>Gambar</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/ReduksiSampahSatpel/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: 'nama_lokasi' },
{ data: 'alamat' },
{ data: 'jenis_lokasi' },
{ data: 'berat' },
{ data: 'gambar' },
]
});
$('#jenis_lokasi').on('change', function() {
const jenisLokasi = $(this).val();
if (jenisLokasi) {
$('#formDetail').removeClass('hidden').hide().fadeIn(300);
populateLokasiDropdown(jenisLokasi);
resetForm();
} else {
$('#formDetail').fadeOut(300);
}
});
});
function closeModal() {
// Reset form
$('#formTambah')[0].reset();
$('#edit_mode').val('false');
$('#modal_title').text('Tambah Reduksi Sampah');
// Close modal
modal_tambah.close();
}
</script>
}