feat:bank sampah unit module
parent
3b624464aa
commit
f25d0fa795
|
|
@ -0,0 +1,278 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankSampahApp.Controllers.Data
|
||||
{
|
||||
[Route("Data/[controller]/[action]")]
|
||||
public class BankSampahUnitController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View("~/Views/Data/BankSampahUnit/Index.cshtml");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Table()
|
||||
{
|
||||
var data = new[]
|
||||
{
|
||||
new {
|
||||
id = 1,
|
||||
nama = "BSI Hijau Lestari",
|
||||
tgl_pendaftaran = "15 Nov 2023",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 2,
|
||||
nama = "BSI Berkah Mandiri",
|
||||
tgl_pendaftaran = "8 Jan 2025",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 3,
|
||||
nama = "BSI Citra Bersama",
|
||||
tgl_pendaftaran = "19 Sep 2023",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 4,
|
||||
nama = "BSI Melati Putih",
|
||||
tgl_pendaftaran = "3 Des 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 5,
|
||||
nama = "BSI Cahaya Sejahtera",
|
||||
tgl_pendaftaran = "27 Apr 2026",
|
||||
status = "Belum Disetujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 6,
|
||||
nama = "BSI Makmur Abadi",
|
||||
tgl_pendaftaran = "11 Jul 2025",
|
||||
status = "Belum Disetujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 7,
|
||||
nama = "BSI Karya Bersama",
|
||||
tgl_pendaftaran = "22 Feb 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 8,
|
||||
nama = "BSI Sumber Rejeki",
|
||||
tgl_pendaftaran = "5 Mei 2023",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 9,
|
||||
nama = "BSI Bumi Asri",
|
||||
tgl_pendaftaran = "14 Jun 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 10,
|
||||
nama = "BSI Alam Indah",
|
||||
tgl_pendaftaran = "30 Okt 2023",
|
||||
status = "Belum Disetujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 11,
|
||||
nama = "BSI Sejahtera Bersama",
|
||||
tgl_pendaftaran = "17 Mar 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 12,
|
||||
nama = "BSI Harapan Jaya",
|
||||
tgl_pendaftaran = "9 Agt 2023",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 13,
|
||||
nama = "BSI Maju Bersama",
|
||||
tgl_pendaftaran = "25 Des 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 14,
|
||||
nama = "BSI Pelangi Nusantara",
|
||||
tgl_pendaftaran = "12 Apr 2024",
|
||||
status = "Belum Disetujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 15,
|
||||
nama = "BSI Serasi Sentosa",
|
||||
tgl_pendaftaran = "6 Jul 2023",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 16,
|
||||
nama = "BSI Griya Daur Ulang",
|
||||
tgl_pendaftaran = "28 Nov 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 17,
|
||||
nama = "BSI Eco Persada",
|
||||
tgl_pendaftaran = "3 Feb 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 18,
|
||||
nama = "BSI Sahabat Lingkungan",
|
||||
tgl_pendaftaran = "19 Mei 2023",
|
||||
status = "Belum Disetujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 19,
|
||||
nama = "BSI Bersih Sejati",
|
||||
tgl_pendaftaran = "7 Sep 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 20,
|
||||
nama = "BSI Nusa Hijau",
|
||||
tgl_pendaftaran = "21 Jan 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 21,
|
||||
nama = "BSI Damai Lestari",
|
||||
tgl_pendaftaran = "15 Okt 2023",
|
||||
status = "Belum Disetujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 22,
|
||||
nama = "BSI Pelita Harapan",
|
||||
tgl_pendaftaran = "4 Jun 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 23,
|
||||
nama = "BSI Mentari Pagi",
|
||||
tgl_pendaftaran = "18 Mar 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 24,
|
||||
nama = "BSI Mitra Alam",
|
||||
tgl_pendaftaran = "10 Agt 2023",
|
||||
status = "Belum Disetujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
id = 25,
|
||||
nama = "BSI Perdana Sentosa",
|
||||
tgl_pendaftaran = "26 Des 2024",
|
||||
status = "Setujui",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] cursor-pointer edit-btn\"><i class=\"ph ph-note-pencil text-white text-sm\"></i></button>" +
|
||||
"<button class=\"p-2 bg-red-500 rounded-full w-[36px] cursor-pointer delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
};
|
||||
|
||||
var response = new
|
||||
{
|
||||
data = data
|
||||
};
|
||||
|
||||
return Json(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,253 @@
|
|||
@{
|
||||
ViewData["Title"] = "Data Bank Sampah Unit";
|
||||
}
|
||||
|
||||
<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']">
|
||||
Data Bank Sampah Unit
|
||||
</span>
|
||||
</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 Bank Sampah Induk</h3>
|
||||
<form id="formTambah" onsubmit="submitForm(event)">
|
||||
<input type="hidden" id="edit_mode" value="false">
|
||||
<input type="hidden" id="bank_sampah_induk_id" value="">
|
||||
<div class="flex flex-col gap-6">
|
||||
<!-- Row 1 -->
|
||||
<!-- <div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
|
||||
<div class="flex flex-col">
|
||||
<fieldset class="fieldset">
|
||||
<legend class="fieldset-legend">
|
||||
Nama
|
||||
<span class="text-red-500">*</span>
|
||||
</legend>
|
||||
<input type="text" id="nama" class="input w-full" placeholder="Nama Bank Sampah Induk" required />
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col">
|
||||
<fieldset class="fieldset">
|
||||
<legend class="fieldset-legend">
|
||||
Tanggal Pendaftaran
|
||||
<span class="text-red-500">*</span>
|
||||
</legend>
|
||||
<input type="date" id="tgl_pendaftaran" class="input w-full" required />
|
||||
</fieldset>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- Row 2 -->
|
||||
<div class="flex flex-col">
|
||||
<fieldset class="fieldset">
|
||||
<legend class="fieldset-legend">
|
||||
Bank Sampah Unit
|
||||
<span class="text-red-500">*</span>
|
||||
</legend>
|
||||
<select id="bsi_f" class="select w-full" required>
|
||||
<option value="" disabled selected>Pilih Bank Sampah Unit</option>
|
||||
<option value="bsi1">BSU Cahaya Sejahtera</option>
|
||||
<option value="bsi2">BSU Mandiri Jaya</option>
|
||||
<option value="bsi3">BSU Harapan Bersama</option>
|
||||
<option value="bsi4">BSU Berkah Abadi</option>
|
||||
<option value="bsi5">BSU Maju Bersama</option>
|
||||
</select>
|
||||
</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 -->
|
||||
|
||||
<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-[50%]">Nama</th>
|
||||
<th class="w-[20%]">Tgl Pendaftaran</th>
|
||||
<th class="w-[15%]">Status</th>
|
||||
<th class="w-[10%]">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@section Scripts {
|
||||
<script type="text/javascript">
|
||||
var table;
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#bsi_f').select2({
|
||||
dropdownParent: $('#modal_tambah'), // Penting untuk modal
|
||||
width: '100%'
|
||||
}
|
||||
);
|
||||
|
||||
table = new DataTable('#example', {
|
||||
ajax: '/Data/BankSampahUnit/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' },
|
||||
{ data: 'tgl_pendaftaran' },
|
||||
{
|
||||
data: 'status',
|
||||
render: function(data, type, row) {
|
||||
if (data === 'Setujui') {
|
||||
return '<div class="px-2 py-1 bg-green-100 rounded-full inline-flex items-center justify-center"><span class="text-green-600 text-xs font-semibold font-[\'Plus_Jakarta_Sans\']">Disetujui</span></div>';
|
||||
} else {
|
||||
return '<div class="px-2 py-1 bg-red-50 rounded-full inline-flex items-center justify-center"><span class="text-red-600 text-xs font-medium font-[\'Plus_Jakarta_Sans\']">Belum Disetujui</span></div>';
|
||||
}
|
||||
}
|
||||
},
|
||||
{ data: 'aksi' },
|
||||
]
|
||||
});
|
||||
|
||||
// Delete button handler
|
||||
$('#example').on('click', '.delete-btn', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var id = $(this).data('id');
|
||||
|
||||
Swal.fire({
|
||||
title: 'Apakah anda yakin?',
|
||||
text: "Data yang dihapus tidak dapat dikembalikan lagi",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Ya, Hapus',
|
||||
cancelButtonText: 'Batal',
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn bg-red-500 text-white hover:bg-red-600 px-4 py-2 rounded-full mr-2',
|
||||
cancelButton: 'btn bg-white text-gray-500 hover:bg-gray-50 px-4 py-2 rounded-full border border-gray-300',
|
||||
},
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// TODO: Implement actual delete API call
|
||||
Swal.fire({
|
||||
title: 'Terhapus!',
|
||||
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', '.edit-btn', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Get row data
|
||||
var row = table.row($(this).parents('tr')).data();
|
||||
|
||||
// Set edit mode
|
||||
$('#edit_mode').val('true');
|
||||
$('#bank_sampah_induk_id').val(row.id);
|
||||
$('#modal_title').text('Edit Data Bank Sampah Induk');
|
||||
|
||||
// Convert date format from "15 Nov 2023" to "2023-11-15"
|
||||
var tglPendaftaran = convertDateToInput(row.tgl_pendaftaran);
|
||||
|
||||
// Populate form with row data
|
||||
$('#nama').val(row.nama);
|
||||
$('#tgl_pendaftaran').val(tglPendaftaran);
|
||||
$('#status').val(row.status);
|
||||
|
||||
// Open modal
|
||||
modal_tambah.showModal();
|
||||
});
|
||||
});
|
||||
|
||||
// Function to convert date format "15 Nov 2023" to "2023-11-15"
|
||||
function convertDateToInput(dateStr) {
|
||||
const monthMap = {
|
||||
'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04',
|
||||
'Mei': '05', 'Jun': '06', 'Jul': '07', 'Agt': '08',
|
||||
'Sep': '09', 'Okt': '10', 'Nov': '11', 'Des': '12'
|
||||
};
|
||||
|
||||
const parts = dateStr.split(' ');
|
||||
const day = parts[0].padStart(2, '0');
|
||||
const month = monthMap[parts[1]];
|
||||
const year = parts[2];
|
||||
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
// Reset form
|
||||
$('#formTambah')[0].reset();
|
||||
$('#edit_mode').val('false');
|
||||
$('#bank_sampah_induk_id').val('');
|
||||
$('#modal_title').text('Tambah Data Bank Sampah Induk');
|
||||
|
||||
// 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();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
<!-- Data -->
|
||||
<li>
|
||||
<details @(new[] { "Nasabah", "BankSampahInduk", "Aktivitas", "HargaSampah", "Offtaker" }.Contains(controller) ? "open" : "")>
|
||||
<details @(new[] { "Nasabah", "BankSampahInduk", "BankSampahUnit", "Aktivitas", "HargaSampah", "Offtaker" }.Contains(controller) ? "open" : "")>
|
||||
<summary>
|
||||
<i class="ph ph-database me-2 text-lg"></i>
|
||||
Data
|
||||
|
|
@ -60,6 +60,7 @@
|
|||
<ul>
|
||||
<li><a href="/Data/Nasabah/Index" class="@(controller == "Nasabah" ? "menu-active" : "")">Nasabah</a></li>
|
||||
<li><a href="/Data/BankSampahInduk/Index" class="@(controller == "BankSampahInduk" ? "menu-active" : "")">Bank Sampah Induk</a></li>
|
||||
<li><a href="/Data/BankSampahUnit/Index" class="@(controller == "BankSampahUnit" ? "menu-active" : "")">Bank Sampah Unit</a></li>
|
||||
<li><a href="/Data/Aktivitas/Index" class="@(controller == "Aktivitas" ? "menu-active" : "")">Aktivitas</a></li>
|
||||
<li><a href="/Data/HargaSampah/Index" class="@(controller == "HargaSampah" ? "menu-active" : "")">Harga Sampah</a></li>
|
||||
<li><a href="/Data/Offtaker/Index" class="@(controller == "Offtaker" ? "menu-active" : "")">Offtaker</a></li>
|
||||
|
|
|
|||
Loading…
Reference in New Issue