348 lines
13 KiB
Plaintext
348 lines
13 KiB
Plaintext
@{
|
|
ViewData["Title"] = "Harga Sampah";
|
|
}
|
|
|
|
<div class="flex flex-col gap-2 md:flex-row md:justify-between md:gap-0">
|
|
<div class="prose">
|
|
<span class="text-xl font-semibold text-gray-900 font-['Plus_Jakarta_Sans']">
|
|
Harga Sampah
|
|
</span>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="flex gap-2">
|
|
|
|
<button id="togglePriceBtn" class="btn btn-sm rounded-full bg-white">
|
|
<i id="eyeIcon" class="ph ph-eye-slash"></i>
|
|
<span id="btnText">Sembunyikan Harga</span>
|
|
</button>
|
|
<button id="toggleSyncBtn" onclick="modal_sync.showModal()"
|
|
class="btn btn-sm rounded-full border border-green-700 text-green-700 bg-white hover:bg-green-50">
|
|
<i class="ph ph-arrows-counter-clockwise"></i>
|
|
<span id="btnText">Referensi Harga BSI</span>
|
|
</button>
|
|
<button class="btn btn-sm rounded-full bg-green-800 text-white hover:bg-green-900" onclick="modal_tambah.showModal()">
|
|
<i class="ph ph-plus"></i>
|
|
Tambah
|
|
</button>
|
|
</div>
|
|
</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-3xl 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 Data Harga Sampah</h3>
|
|
<form id="formTambah" onsubmit="submitForm(event)">
|
|
<input type="hidden" id="edit_mode" value="false">
|
|
<div class="flex flex-col gap-6">
|
|
<!-- Row 1 -->
|
|
<div class="flex flex-col">
|
|
<fieldset class="fieldset">
|
|
<legend class="fieldset-legend">
|
|
Nama Subkategori Sampah
|
|
<span class="text-red-500">*</span>
|
|
</legend>
|
|
<input type="text" id="nama_subkategori" class="input w-full" placeholder="Nama Subkategori Sampah" required />
|
|
</fieldset>
|
|
</div>
|
|
|
|
<!-- Row 2 -->
|
|
<div class="flex flex-col">
|
|
<fieldset class="fieldset">
|
|
<legend class="fieldset-legend">
|
|
Harga (Rp)
|
|
<span class="text-red-500">*</span>
|
|
</legend>
|
|
<input type="number" id="harga" class="input w-full" placeholder="Harga (Rp)" required />
|
|
</fieldset>
|
|
</div>
|
|
|
|
<!-- Buttons -->
|
|
<div class="flex 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" 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">
|
|
Simpan
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<form method="dialog" class="modal-backdrop">
|
|
<button>close</button>
|
|
</form>
|
|
</dialog>
|
|
<!-- /modal tambah/edit -->
|
|
|
|
<!-- Modal Hide Harga -->
|
|
<dialog id="modal_hide" class="modal modal-bottom sm:modal-middle">
|
|
<div class="modal-box w-full max-w-lg p-6 bg-white rounded-2xl">
|
|
|
|
<!-- Header -->
|
|
<div class="flex items-start justify-between mb-4">
|
|
<div class="flex items-center gap-2">
|
|
<i class="ph ph-info text-red-500 text-xl"></i>
|
|
</div>
|
|
<button onclick="modal_hide.close()" class="text-gray-500 hover:text-gray-700 cursor-pointer">
|
|
<i class="ph ph-x text-lg"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Message -->
|
|
<p class="text-gray-700 leading-relaxed mb-8 text-base">
|
|
Apakah Anda yakin ingin menyembunyikan (hide) harga sampah ini dari tampilan publik pada halaman Landing Page?
|
|
</p>
|
|
|
|
<!-- Buttons -->
|
|
<form id="formHide" onsubmit="submitFormHide(event)">
|
|
<div class="flex justify-end gap-3">
|
|
<button type="button" onclick="modal_hide.close()"
|
|
class="px-8 py-2.5 bg-white rounded-full outline outline-1 outline-gray-300 text-gray-700 font-semibold hover:bg-gray-50">
|
|
Tidak
|
|
</button>
|
|
|
|
<button type="submit"
|
|
class="px-8 py-2.5 bg-green-800 rounded-full text-white font-semibold hover:bg-green-900 cursor-pointer">
|
|
Ya
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<form method="dialog" class="modal-backdrop">
|
|
<button>close</button>
|
|
</form>
|
|
</dialog>
|
|
|
|
<!-- End Modal Hide Harga -->
|
|
|
|
<!-- Modal Sync -->
|
|
<dialog id="modal_sync" class="modal modal-bottom sm:modal-middle">
|
|
<div class="modal-box w-full max-w-2xl p-6 bg-white rounded-2xl shadow">
|
|
|
|
<!-- Header -->
|
|
<div class="flex items-start justify-between mb-5">
|
|
<div class="flex items-center gap-2">
|
|
<i class="ph ph-info text-red-500 text-2xl"></i>
|
|
</div>
|
|
<button onclick="modal_sync.close()" class="text-gray-500 hover:text-gray-700 cursor-pointer">
|
|
<i class="ph ph-x text-xl"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Main Question -->
|
|
<p class="text-gray-900 text-base leading-relaxed mb-4">
|
|
Apakah Anda yakin ingin menyamakan data harga sampah BSU ini dengan
|
|
data harga sampah yang ada di BSI?
|
|
</p>
|
|
|
|
<!-- Warning Box -->
|
|
<div class="bg-orange-50 border border-orange-200 text-orange-700 px-4 py-3 rounded-xl mb-8">
|
|
Tindakan ini akan mengganti seluruh data harga sampah pada BSU dengan data terbaru dari BSI.
|
|
</div>
|
|
|
|
<!-- Buttons -->
|
|
<form id="formSync" onsubmit="submitSync(event)">
|
|
<div class="flex justify-end gap-3">
|
|
|
|
<!-- Cancel -->
|
|
<button type="button" onclick="modal_sync.close()"
|
|
class="px-8 py-2.5 bg-white rounded-full outline outline-1 outline-gray-300
|
|
text-gray-700 font-semibold hover:bg-gray-50 cursor-pointer">
|
|
Tidak
|
|
</button>
|
|
|
|
<!-- Confirm -->
|
|
<button type="submit"
|
|
class="px-8 py-2.5 bg-green-800 rounded-full text-white font-semibold
|
|
hover:bg-green-900 cursor-pointer">
|
|
Ya, Samakan Data
|
|
</button>
|
|
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<form method="dialog" class="modal-backdrop">
|
|
<button>close</button>
|
|
</form>
|
|
</dialog>
|
|
|
|
<!-- End Modal Sync -->
|
|
|
|
<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 class="w-[10%]">No</th>
|
|
<th class="w-[60%]">Nama Subkategori Sampah</th>
|
|
<th class="w-[20%]">Harga (Rp)</th>
|
|
<th class="w-[10%]">Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@section Scripts {
|
|
<script type="text/javascript">
|
|
var table;
|
|
var isHidden = false;
|
|
|
|
$(document).ready(function () {
|
|
table = new DataTable('#example', {
|
|
ajax: '/Data/HargaSampah/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_subkategori' },
|
|
{
|
|
data: 'harga',
|
|
render: function(data) {
|
|
if (isHidden) {
|
|
return '********';
|
|
}
|
|
return new Intl.NumberFormat('id-ID').format(data);
|
|
}
|
|
},
|
|
{ data: 'aksi' },
|
|
]
|
|
});
|
|
|
|
// Delete button handler
|
|
$('#example').on('click', '.p-2.bg-red-500', function (e) {
|
|
e.preventDefault();
|
|
|
|
Swal.fire({
|
|
title: 'Anda yakin ingin menghapus data ini?',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya',
|
|
cancelButtonText: 'Tidak',
|
|
buttonsStyling: false,
|
|
customClass: {
|
|
confirmButton: 'btn bg-green-800 text-white hover:bg-green-900 px-8 py-2 rounded-full mr-2',
|
|
cancelButton: 'btn bg-white text-gray-500 hover:bg-gray-50 px-8 py-2 rounded-full border border-gray-300',
|
|
},
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
// TODO: Implement actual delete API call
|
|
Swal.fire({
|
|
title: 'Berhasil!',
|
|
text: 'Data berhasil dihapus.',
|
|
icon: 'success',
|
|
confirmButtonText: 'OK',
|
|
buttonsStyling: false,
|
|
customClass: {
|
|
confirmButton: 'btn bg-green-800 text-white hover:bg-green-900 px-4 py-2 rounded-full',
|
|
},
|
|
}).then(() => {
|
|
// Reload table
|
|
table.ajax.reload();
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// Edit button handler
|
|
$('#example').on('click', '.p-2.bg-amber-500', function (e) {
|
|
e.preventDefault();
|
|
|
|
// Get row data
|
|
var row = table.row($(this).parents('tr')).data();
|
|
|
|
// Set edit mode
|
|
$('#edit_mode').val('true');
|
|
$('#modal_title').text('Edit Data Harga Sampah');
|
|
|
|
// Populate form with row data
|
|
$('#nama_subkategori').val(row.nama_subkategori);
|
|
$('#harga').val(row.harga);
|
|
|
|
// Open modal
|
|
modal_tambah.showModal();
|
|
});
|
|
|
|
$('#togglePriceBtn').on('click', function() {
|
|
modal_hide.showModal();
|
|
});
|
|
});
|
|
|
|
function closeModal() {
|
|
// Reset form
|
|
$('#formTambah')[0].reset();
|
|
$('#edit_mode').val('false');
|
|
$('#modal_title').text('Tambah Data Harga Sampah');
|
|
|
|
// Close modal
|
|
modal_tambah.close();
|
|
}
|
|
|
|
function submitForm(e) {
|
|
e.preventDefault();
|
|
|
|
var isEditMode = $('#edit_mode').val() === 'true';
|
|
|
|
// TODO: Implement form submission logic
|
|
Swal.fire({
|
|
title: 'Berhasil!',
|
|
text: isEditMode ? 'Data berhasil diperbarui' : 'Data berhasil ditambahkan',
|
|
icon: 'success',
|
|
confirmButtonText: 'OK',
|
|
buttonsStyling: false,
|
|
customClass: {
|
|
confirmButton: 'btn bg-green-800 text-white hover:bg-green-900 px-4 py-2 rounded-full',
|
|
},
|
|
}).then(() => {
|
|
closeModal();
|
|
|
|
// Reload table
|
|
table.ajax.reload();
|
|
});
|
|
}
|
|
|
|
function submitFormHide(e){
|
|
e.preventDefault();
|
|
modal_hide.close();
|
|
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Sukses!',
|
|
text: 'Data harga berhasil di sembunyikan.',
|
|
timer: 1000,
|
|
showConfirmButton: false
|
|
});
|
|
}
|
|
|
|
function submitSync(e){
|
|
e.preventDefault();
|
|
modal_sync.close();
|
|
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Sukses!',
|
|
text: 'Data harga berhasil disamakan.',
|
|
timer: 1000,
|
|
showConfirmButton: false
|
|
});
|
|
}
|
|
</script>
|
|
}
|