feat: menu transaksi nasabah
parent
7242c9f7d1
commit
940b88f3af
|
|
@ -0,0 +1,278 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankSampahApp.Controllers.Main
|
||||
{
|
||||
[Route("Main/[controller]/[action]")]
|
||||
public class TransaksiNasabahController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View("~/Views/Main/TransaksiNasabah/Index.cshtml");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Table()
|
||||
{
|
||||
var data = new[]
|
||||
{
|
||||
new {
|
||||
tgl_transaksi = "15 Nov 2023",
|
||||
nama_bank_samoah = "RW 09 Kalisari",
|
||||
nilai_transaksi = "150,000",
|
||||
total_sampah = 67,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "8 Jan 2025",
|
||||
nama_bank_samoah = "RW 09 Kalisari",
|
||||
nilai_transaksi = "175,000",
|
||||
total_sampah = 24,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "19 Sep 2023",
|
||||
nama_bank_samoah = "RW 09 Kalisari",
|
||||
nilai_transaksi = "160,000",
|
||||
total_sampah = 54,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "3 Des 2024",
|
||||
nama_bank_samoah = "RW 09 Kalisari",
|
||||
nilai_transaksi = "180,000",
|
||||
total_sampah = 89,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "27 Apr 2026",
|
||||
nama_bank_samoah = "RW 09 Kalisari",
|
||||
nilai_transaksi = "190,000",
|
||||
total_sampah = 12,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "11 Jul 2025",
|
||||
nama_bank_samoah = "RW 09 Kalisari",
|
||||
nilai_transaksi = "200,000",
|
||||
total_sampah = 32,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "2 Feb 2024",
|
||||
nama_bank_samoah = "Berkah Sampah",
|
||||
nilai_transaksi = "145,000",
|
||||
total_sampah = 78,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "18 Mar 2024",
|
||||
nama_bank_samoah = "Pelangi Persada",
|
||||
nilai_transaksi = "220,000",
|
||||
total_sampah = 95,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "25 May 2024",
|
||||
nama_bank_samoah = "Eco Makmur",
|
||||
nilai_transaksi = "135,000",
|
||||
total_sampah = 43,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "7 Jun 2024",
|
||||
nama_bank_samoah = "Griya Daur Ulang",
|
||||
nilai_transaksi = "165,000",
|
||||
total_sampah = 61,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "14 Jul 2024",
|
||||
nama_bank_samoah = "Bank Sampah Induk",
|
||||
nilai_transaksi = "195,000",
|
||||
total_sampah = 87,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "22 Agt 2024",
|
||||
nama_bank_samoah = "Ceria Hijau",
|
||||
nilai_transaksi = "128,000",
|
||||
total_sampah = 38,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "5 Sep 2024",
|
||||
nama_bank_samoah = "Hijau Lestari",
|
||||
nilai_transaksi = "210,000",
|
||||
total_sampah = 102,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "11 Okt 2024",
|
||||
nama_bank_samoah = "Sahabat Bumi",
|
||||
nilai_transaksi = "142,000",
|
||||
total_sampah = 56,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "19 Nov 2024",
|
||||
nama_bank_samoah = "Bersih Sejahtera",
|
||||
nilai_transaksi = "185,000",
|
||||
total_sampah = 73,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "28 Des 2024",
|
||||
nama_bank_samoah = "Karya Mandiri",
|
||||
nilai_transaksi = "155,000",
|
||||
total_sampah = 49,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "4 Jan 2025",
|
||||
nama_bank_samoah = "Bumi Asri",
|
||||
nilai_transaksi = "230,000",
|
||||
total_sampah = 118,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "12 Feb 2025",
|
||||
nama_bank_samoah = "Lestari Alam",
|
||||
nilai_transaksi = "172,000",
|
||||
total_sampah = 65,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "21 Mar 2025",
|
||||
nama_bank_samoah = "Mandiri Sejahtera",
|
||||
nilai_transaksi = "198,000",
|
||||
total_sampah = 91,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "30 Apr 2025",
|
||||
nama_bank_samoah = "Cahaya Bersih",
|
||||
nilai_transaksi = "138,000",
|
||||
total_sampah = 47,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "9 May 2025",
|
||||
nama_bank_samoah = "Hijau Persada",
|
||||
nilai_transaksi = "215,000",
|
||||
total_sampah = 104,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "16 Jun 2025",
|
||||
nama_bank_samoah = "Nusa Indah",
|
||||
nilai_transaksi = "163,000",
|
||||
total_sampah = 58,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "25 Jul 2025",
|
||||
nama_bank_samoah = "Melati Putih",
|
||||
nilai_transaksi = "188,000",
|
||||
total_sampah = 82,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "3 Agt 2025",
|
||||
nama_bank_samoah = "Sejahtera Bersama",
|
||||
nilai_transaksi = "205,000",
|
||||
total_sampah = 96,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] delete-btn\"><i class=\"ph ph-trash text-white text-sm\"></i></button>" +
|
||||
"</div>",
|
||||
},
|
||||
new {
|
||||
tgl_transaksi = "10 Sep 2025",
|
||||
nama_bank_samoah = "Asri Jaya",
|
||||
nilai_transaksi = "149,000",
|
||||
total_sampah = 52,
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<button class=\"p-2 bg-amber-500 rounded-full w-[36px] h-[36px] 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] h-[36px] 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,280 @@
|
|||
@{
|
||||
ViewData["Title"] = "Transaksi Nasabah";
|
||||
}
|
||||
|
||||
<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']">
|
||||
Transaksi Saya
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<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>
|
||||
|
||||
<!-- 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 Transaksi</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="grid grid-cols-1 sm:grid-cols-2 gap-6">
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<label class="text-slate-800 text-base font-normal font-['Plus_Jakarta_Sans'] leading-6">
|
||||
Tanggal Transaksi
|
||||
<span class="text-red-500 text-sm font-semibold">*</span>
|
||||
</label>
|
||||
<input type="date" id="tgl_transaksi" class="px-3.5 py-3 bg-white rounded-lg outline outline-1 outline-offset-[-1px] outline-gray-300 text-base font-['Plus_Jakarta_Sans'] focus:outline-2 focus:outline-green-800" required />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<label class="text-slate-800 text-base font-normal font-['Plus_Jakarta_Sans'] leading-6">
|
||||
Nama Bank Sampah
|
||||
<span class="text-red-500 text-sm font-semibold">*</span>
|
||||
</label>
|
||||
<select id="nama_bank_samoah" class="px-3.5 py-3 bg-white rounded-lg outline outline-1 outline-offset-[-1px] outline-gray-300 text-base font-['Plus_Jakarta_Sans'] text-slate-800 focus:outline-2 focus:outline-green-800" required>
|
||||
<option value="" class="text-gray-400">Pilih Bank Sampah</option>
|
||||
<option value="RW 09 Kalisari" class="text-slate-800">RW 09 Kalisari</option>
|
||||
<option value="Berkah Sampah" class="text-slate-800">Berkah Sampah</option>
|
||||
<option value="Pelangi Persada" class="text-slate-800">Pelangi Persada</option>
|
||||
<option value="Eco Makmur" class="text-slate-800">Eco Makmur</option>
|
||||
<option value="Griya Daur Ulang" class="text-slate-800">Griya Daur Ulang</option>
|
||||
<option value="Bank Sampah Induk" class="text-slate-800">Bank Sampah Induk</option>
|
||||
<option value="Ceria Hijau" class="text-slate-800">Ceria Hijau</option>
|
||||
<option value="Hijau Lestari" class="text-slate-800">Hijau Lestari</option>
|
||||
<option value="Sahabat Bumi" class="text-slate-800">Sahabat Bumi</option>
|
||||
<option value="Bersih Sejahtera" class="text-slate-800">Bersih Sejahtera</option>
|
||||
<option value="Karya Mandiri" class="text-slate-800">Karya Mandiri</option>
|
||||
<option value="Bumi Asri" class="text-slate-800">Bumi Asri</option>
|
||||
<option value="Lestari Alam" class="text-slate-800">Lestari Alam</option>
|
||||
<option value="Mandiri Sejahtera" class="text-slate-800">Mandiri Sejahtera</option>
|
||||
<option value="Cahaya Bersih" class="text-slate-800">Cahaya Bersih</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Row 2 -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<label class="text-slate-800 text-base font-normal font-['Plus_Jakarta_Sans'] leading-6">
|
||||
Nilai Transaksi (Rp)
|
||||
<span class="text-red-500 text-sm font-semibold">*</span>
|
||||
</label>
|
||||
<input type="text" id="nilai_transaksi" class="px-3.5 py-3 bg-white rounded-lg outline outline-1 outline-offset-[-1px] outline-gray-300 text-base font-['Plus_Jakarta_Sans'] placeholder:text-gray-400 focus:outline-2 focus:outline-green-800" placeholder="150,000" required />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<label class="text-slate-800 text-base font-normal font-['Plus_Jakarta_Sans'] leading-6">
|
||||
Total Sampah (Kg)
|
||||
<span class="text-red-500 text-sm font-semibold">*</span>
|
||||
</label>
|
||||
<input type="number" id="total_sampah" class="px-3.5 py-3 bg-white rounded-lg outline outline-1 outline-offset-[-1px] outline-gray-300 text-base font-['Plus_Jakarta_Sans'] placeholder:text-gray-400 focus:outline-2 focus:outline-green-800" placeholder="67" required />
|
||||
</div>
|
||||
</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-[-1px] 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 sm:p-4">
|
||||
<div class="w-full overflow-x-auto">
|
||||
<table class="table-zebra table w-full" id="example">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-[5%]">No</th>
|
||||
<th class="w-[15%]">Tgl Transaksi</th>
|
||||
<th class="w-[25%]">Nama Bank Samoah</th>
|
||||
<th class="w-[20%]">Nilai Transaksi</th>
|
||||
<th class="w-[15%]">Total Sampah</th>
|
||||
<th class="w-[10%]">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script src="https://cdn.datatables.net/2.3.4/js/dataTables.js"></script>
|
||||
<script src="/plugins/datatables/dataTables.tailwindcss.js"></script>
|
||||
<script type="text/javascript">
|
||||
var table;
|
||||
|
||||
$(document).ready(function () {
|
||||
table = new DataTable('#example', {
|
||||
ajax: '/Main/TransaksiNasabah/Table',
|
||||
scrollX: true,
|
||||
autoWidth: false,
|
||||
responsive: 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: 'tgl_transaksi' },
|
||||
{ data: 'nama_bank_samoah' },
|
||||
{ data: 'nilai_transaksi' },
|
||||
{ data: 'total_sampah' },
|
||||
{ data: 'aksi' },
|
||||
]
|
||||
});
|
||||
|
||||
// Delete button handler
|
||||
$('#example').on('click', '.delete-btn', 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', '.edit-btn', 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 Transaksi');
|
||||
|
||||
// Convert date format from "15 Nov 2023" to "2023-11-15"
|
||||
var tglTransaksi = convertDateToInput(row.tgl_transaksi);
|
||||
|
||||
// Populate form with row data
|
||||
$('#tgl_transaksi').val(tglTransaksi);
|
||||
$('#nama_bank_samoah').val(row.nama_bank_samoah);
|
||||
$('#nilai_transaksi').val(row.nilai_transaksi);
|
||||
$('#total_sampah').val(row.total_sampah);
|
||||
|
||||
// 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');
|
||||
$('#modal_title').text('Tambah Transaksi');
|
||||
|
||||
// Close modal
|
||||
modal_tambah.close();
|
||||
}
|
||||
|
||||
function submitForm(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var isEditMode = $('#edit_mode').val() === 'true';
|
||||
|
||||
// Get form data
|
||||
var tglTransaksi = $('#tgl_transaksi').val();
|
||||
var namaBankSamoah = $('#nama_bank_samoah').val();
|
||||
var nilaiTransaksi = $('#nilai_transaksi').val();
|
||||
var totalSampah = $('#total_sampah').val();
|
||||
|
||||
// Validate
|
||||
if (!tglTransaksi || !namaBankSamoah || !nilaiTransaksi || !totalSampah) {
|
||||
Swal.fire({
|
||||
title: 'Error!',
|
||||
text: 'Mohon lengkapi semua field yang wajib diisi',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK',
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn bg-green-800 text-white hover:bg-green-900 px-4 py-2 rounded-full',
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 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>
|
||||
|
|
@ -187,6 +187,14 @@
|
|||
Bank Sampah Nasabah
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Transaksi Nasabah -->
|
||||
<li>
|
||||
<a asp-controller="TransaksiNasabah" asp-action="Index" class="rounded-full @(controller == "TransaksiNasabah" ? "menu-active" : "")">
|
||||
<i class="ph ph-currency-circle-dollar me-2 text-lg"></i>
|
||||
Transaksi Nasabah
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue