Filter periode member + harga otomatis + soft delete arsip + ganti alert ke Swal
This commit is contained in:
@@ -96,6 +96,16 @@ $(document).ready(function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Jumlahkan tarif semua kendaraan di list -> isi otomatis ke Harga.
|
||||
// Harga dikirim angka polos (kolom double), tanpa pemisah ribuan.
|
||||
function updateHarga() {
|
||||
let total = 0;
|
||||
$("#modal-member #list-nopol tr").each(function () {
|
||||
total += parseFloat($(this).data("tarif")) || 0;
|
||||
});
|
||||
$("#modal-member input[name='harga']").val(total);
|
||||
}
|
||||
|
||||
$("#nopol-add").on("click", function () {
|
||||
var nopol = $(".nopol-add").val().trim();
|
||||
console.log(nopol);
|
||||
@@ -103,6 +113,7 @@ $(document).ready(function () {
|
||||
var vehicle = $("#jenisVehicle").val();
|
||||
var vehicleName = $("#jenisVehicle option:selected").text();
|
||||
var member = $("#jenis-member option:selected").text();
|
||||
var tarif = parseFloat($("#jenis-member").val()) || 0;
|
||||
var merk = $(".merk").val().trim();
|
||||
$(".nopol-add").removeClass("is-invalid"); // Hapus kelas jika ada sebelumnya
|
||||
$(".nopol-add").next(".invalid-feedback").hide();
|
||||
@@ -120,7 +131,7 @@ $(document).ready(function () {
|
||||
success: function (r) {
|
||||
if (r.response === true) {
|
||||
var rowhtml = `
|
||||
<tr>
|
||||
<tr data-tarif="${tarif}">
|
||||
<td class="text-center">${nopol}</td>
|
||||
<td class="text-center" data-value="${vehicle}">${vehicleName}</td>
|
||||
<td class="text-center">${member}</td>
|
||||
@@ -132,6 +143,7 @@ $(document).ready(function () {
|
||||
`;
|
||||
$("#list-nopol").append(rowhtml);
|
||||
console.log("Berhasil menambahkan " + nopol);
|
||||
updateHarga();
|
||||
|
||||
$(".nopol-add").val("");
|
||||
$("#jenisVehicle").val("");
|
||||
@@ -195,6 +207,11 @@ $(document).ready(function () {
|
||||
$(this).closest("tr").remove(); // Hapus baris yang diklik
|
||||
});
|
||||
|
||||
$("#list-nopol").on("click", ".delete-row", function () {
|
||||
$(this).closest("tr").remove();
|
||||
updateHarga();
|
||||
});
|
||||
|
||||
$(".simpan").on("click", function () {
|
||||
var tombol = $(this);
|
||||
var formCollect = $("#add-member").serialize();
|
||||
@@ -243,6 +260,9 @@ $(document).ready(function () {
|
||||
cardNumber: cardCollect,
|
||||
};
|
||||
|
||||
updateHarga(); // pastikan harga = jumlah tarif kendaraan sebelum simpan
|
||||
formDataObj.harga = $("#modal-member input[name='harga']").val();
|
||||
|
||||
if ($(".tambah-member").valid()) {
|
||||
const saveHtml = tombol.html();
|
||||
$.ajax({
|
||||
|
||||
Reference in New Issue
Block a user