feat:module sedekah sampah
parent
0101a9e7fc
commit
940751acc2
|
|
@ -0,0 +1,178 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace BankSampahApp.Controllers.Master
|
||||||
|
{
|
||||||
|
[Route("Transaksi/[controller]/[action]")]
|
||||||
|
public class SedekahSampahController : Controller
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View("~/Views/Transaksi/SedekahSampah/Index.cshtml");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Table()
|
||||||
|
{
|
||||||
|
var data = new[]
|
||||||
|
{
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "23 Mei 2025",
|
||||||
|
nama_nasabah = "Siti Aminah",
|
||||||
|
total_sedekah = 289000,
|
||||||
|
total_sampah = 560120,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "24 Mei 2025",
|
||||||
|
nama_nasabah = "Budi Hartono",
|
||||||
|
total_sedekah = 175000,
|
||||||
|
total_sampah = 42,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "25 Mei 2025",
|
||||||
|
nama_nasabah = "Rina Widya",
|
||||||
|
total_sedekah = 94000,
|
||||||
|
total_sampah = 31,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "26 Mei 2025",
|
||||||
|
nama_nasabah = "Ahmad Fauzi",
|
||||||
|
total_sedekah = 215000,
|
||||||
|
total_sampah = 58,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "27 Mei 2025",
|
||||||
|
nama_nasabah = "Nurhayati",
|
||||||
|
total_sedekah = 132000,
|
||||||
|
total_sampah = 24,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "28 Mei 2025",
|
||||||
|
nama_nasabah = "Dewi Anggraini",
|
||||||
|
total_sedekah = 305000,
|
||||||
|
total_sampah = 63,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "29 Mei 2025",
|
||||||
|
nama_nasabah = "Heri Susanto",
|
||||||
|
total_sedekah = 164000,
|
||||||
|
total_sampah = 37,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "30 Mei 2025",
|
||||||
|
nama_nasabah = "Yuni Marlina",
|
||||||
|
total_sedekah = 92000,
|
||||||
|
total_sampah = 18,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "31 Mei 2025",
|
||||||
|
nama_nasabah = "Agus Setiawan",
|
||||||
|
total_sedekah = 187000,
|
||||||
|
total_sampah = 52,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "1 Juni 2025",
|
||||||
|
nama_nasabah = "Lestari Kumala",
|
||||||
|
total_sedekah = 256000,
|
||||||
|
total_sampah = 74,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "2 Juni 2025",
|
||||||
|
nama_nasabah = "Rizky Saputra",
|
||||||
|
total_sedekah = 110000,
|
||||||
|
total_sampah = 29,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "3 Juni 2025",
|
||||||
|
nama_nasabah = "Indah Pratiwi",
|
||||||
|
total_sedekah = 195000,
|
||||||
|
total_sampah = 46,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "4 Juni 2025",
|
||||||
|
nama_nasabah = "Wahyu Hidayat",
|
||||||
|
total_sedekah = 89000,
|
||||||
|
total_sampah = 17,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "5 Juni 2025",
|
||||||
|
nama_nasabah = "Nadia Ramadhani",
|
||||||
|
total_sedekah = 320000,
|
||||||
|
total_sampah = 81,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
tanggal_transaksi = "6 Juni 2025",
|
||||||
|
nama_nasabah = "Fajar Maulana",
|
||||||
|
total_sedekah = 143000,
|
||||||
|
total_sampah = 33,
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var response = new
|
||||||
|
{
|
||||||
|
data = data
|
||||||
|
};
|
||||||
|
|
||||||
|
return Json(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -88,13 +88,14 @@
|
||||||
|
|
||||||
<!-- Transaksi -->
|
<!-- Transaksi -->
|
||||||
<li>
|
<li>
|
||||||
<details @(new[] { "Nasabah", "PenarikanTabungan", "Bsi", "TransaksiOfftaker", "LaporanTransaksi" }.Contains(controller) ? "open" : "")>
|
<details @(new[] { "Nasabah", "PenarikanTabungan", "Bsi", "TransaksiOfftaker", "LaporanTransaksi", "SedekahSampah" }.Contains(controller) ? "open" : "")>
|
||||||
<summary>
|
<summary>
|
||||||
<i class="ph ph-cash-register me-2 text-lg"></i>
|
<i class="ph ph-cash-register me-2 text-lg"></i>
|
||||||
Transaksi
|
Transaksi
|
||||||
</summary>
|
</summary>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/Transaksi/Nasabah/Index" class="@(controller == "Nasabah" ? "menu-active" : "")">Nasabah</a></li>
|
<li><a href="/Transaksi/Nasabah/Index" class="@(controller == "Nasabah" ? "menu-active" : "")">Nasabah</a></li>
|
||||||
|
<li><a href="/Transaksi/SedekahSampah/Index" class="@(controller == "SedekahSampah" ? "menu-active" : "")">Sedekah Sampah</a></li>
|
||||||
<li><a href="/Transaksi/PenarikanTabungan/Index" class="@(controller == "PenarikanTabungan" ? "menu-active" : "")">Penarikan Tabungan</a></li>
|
<li><a href="/Transaksi/PenarikanTabungan/Index" class="@(controller == "PenarikanTabungan" ? "menu-active" : "")">Penarikan Tabungan</a></li>
|
||||||
<li><a href="/Transaksi/Bsi/Index" class="@(controller == "Bsi" ? "menu-active" : "")">BSI</a></li>
|
<li><a href="/Transaksi/Bsi/Index" class="@(controller == "Bsi" ? "menu-active" : "")">BSI</a></li>
|
||||||
<li><a href="/Transaksi/TransaksiOfftaker/Index" class="@(controller == "TransaksiOfftaker" ? "menu-active" : "")">Offtaker</a></li>
|
<li><a href="/Transaksi/TransaksiOfftaker/Index" class="@(controller == "TransaksiOfftaker" ? "menu-active" : "")">Offtaker</a></li>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,248 @@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Sedekah 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-black">
|
||||||
|
Sedekah Sampah
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-2 md:flex-row">
|
||||||
|
<button class="btn btn-sm bg-green-800 max-w-full rounded-full text-white hover:bg-green-900" onclick="modal_tambah.showModal()">
|
||||||
|
Tambah
|
||||||
|
<i class="ph ph-plus"></i>
|
||||||
|
</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 Sedekah Sampah</h3>
|
||||||
|
<form id="formTambah" onsubmit="submitForm(event)">
|
||||||
|
<input type="hidden" id="edit_mode" value="false">
|
||||||
|
<div class="flex flex-col gap-6">
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-3 gap-6">
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<fieldset class="fieldset">
|
||||||
|
<legend class="fieldset-legend">
|
||||||
|
Tanggal Transaksi
|
||||||
|
<span class="text-red-500">*</span>
|
||||||
|
</legend>
|
||||||
|
<input type="date" id="tgl_transaksi" class="input w-full" required />
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<fieldset class="fieldset">
|
||||||
|
<legend class="fieldset-legend">
|
||||||
|
Nama Petugas<span class="text-red-500">*</span>
|
||||||
|
</legend>
|
||||||
|
<input type="text" id="nama" class="input w-full" placeholder="Nama Petugas" required />
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<fieldset class="fieldset">
|
||||||
|
<legend class="fieldset-legend">
|
||||||
|
Nama Nasabah<span class="text-red-500">*</span>
|
||||||
|
</legend>
|
||||||
|
<input type="text" id="nama" class="input w-full" placeholder="Nama Petugas" required />
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="divider"></div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-[1fr_1fr_auto] gap-4 items-end mb-4">
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<fieldset class="fieldset">
|
||||||
|
<legend class="fieldset-legend">
|
||||||
|
Jenis Sampah
|
||||||
|
<span class="text-red-500">*</span>
|
||||||
|
</legend>
|
||||||
|
<select id="jenis_sampah" class="select w-full" required>
|
||||||
|
<option value="" disabled selected>Pilih Jenis Sampah</option>
|
||||||
|
</select>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<fieldset class="fieldset">
|
||||||
|
<legend class="fieldset-legend">
|
||||||
|
Berat Sampah (Kg)
|
||||||
|
<span class="text-red-500">*</span>
|
||||||
|
</legend>
|
||||||
|
<select id="jenis_sampah" class="select w-full" required>
|
||||||
|
<option value="" disabled selected>Pilih Jenis Sampah</option>
|
||||||
|
</select>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a href="#" class="mt-8 btn btn-circle btn-error delete text-white justify-self-end"><i class="ph ph-trash"></i></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-end items-center">
|
||||||
|
<button type="button" class="btn btn-sm rounded-full bg-white">
|
||||||
|
Tambah Jenis Sampah
|
||||||
|
<i class="ph ph-plus"></i>
|
||||||
|
</button>
|
||||||
|
</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">
|
||||||
|
<div class="card-body p-2">
|
||||||
|
<div class="w-full overflow-x-auto">
|
||||||
|
<table class="table-zebra table" id="example">
|
||||||
|
<!-- head -->
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="w-[5%]">No</th>
|
||||||
|
<th class="w-[50%]">Tanggal Transaksi</th>
|
||||||
|
<th class="w-[35%]">Nama Nasabah</th>
|
||||||
|
<th class="w-[35%]">Total Sedekah (Rp)</th>
|
||||||
|
<th class="w-[35%]">Total Sampah (Kg)</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 () {
|
||||||
|
table = new DataTable('#example', {
|
||||||
|
ajax: '/Transaksi/SedekahSampah/Table',
|
||||||
|
scrollX: true,
|
||||||
|
autoWidth: true,
|
||||||
|
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: 'tanggal_transaksi' },
|
||||||
|
{ data: 'nama_nasabah' },
|
||||||
|
{ data: 'total_sedekah' },
|
||||||
|
{ data: 'total_sampah' },
|
||||||
|
{ data: 'aksi' },
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// Delete button handler
|
||||||
|
$('#example').on('click', '.btn-circle.btn-error', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
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', '.btn-circle.btn-warning', 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 Sedekah Sampah');
|
||||||
|
|
||||||
|
// Populate form with row data
|
||||||
|
$('#nama').val(row.nama);
|
||||||
|
|
||||||
|
// Open modal
|
||||||
|
modal_tambah.showModal();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
// Reset form
|
||||||
|
$('#formTambah')[0].reset();
|
||||||
|
$('#edit_mode').val('false');
|
||||||
|
$('#modal_title').text('Tambah Fasilitas');
|
||||||
|
|
||||||
|
// 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>
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue