Filter periode member + harga otomatis + soft delete arsip + ganti alert ke Swal
This commit is contained in:
@@ -39,6 +39,25 @@ $(document).ready(function () {
|
||||
|
||||
var url = $("#example").data("url");
|
||||
|
||||
// Satu input periode (date-range) -> isi hidden tgl_awal/tgl_akhir (YYYY-MM-DD).
|
||||
if ($.fn.daterangepicker && $(".input-daterange-filter").length) {
|
||||
$(".input-daterange-filter").daterangepicker({
|
||||
autoUpdateInput: false,
|
||||
locale: { format: "DD-MM-YYYY", cancelLabel: "Hapus" },
|
||||
parentEl: "#search-form",
|
||||
});
|
||||
$(".input-daterange-filter").on("apply.daterangepicker", function (ev, picker) {
|
||||
$(this).val(picker.startDate.format("DD-MM-YYYY") + " - " + picker.endDate.format("DD-MM-YYYY"));
|
||||
$("#tgl-awal").val(picker.startDate.format("YYYY-MM-DD"));
|
||||
$("#tgl-akhir").val(picker.endDate.format("YYYY-MM-DD"));
|
||||
});
|
||||
$(".input-daterange-filter").on("cancel.daterangepicker", function () {
|
||||
$(this).val("");
|
||||
$("#tgl-awal").val("");
|
||||
$("#tgl-akhir").val("");
|
||||
});
|
||||
}
|
||||
|
||||
$("#search-button").on("click", function () {
|
||||
let searchBy = $("#search-by").val();
|
||||
let searchValue = $("#search-value").val().trim();
|
||||
@@ -60,7 +79,7 @@ $(document).ready(function () {
|
||||
notrans: "No. Transaksi",
|
||||
};
|
||||
|
||||
alert("Harap masukkan " + (label[searchBy] || "kata kunci"));
|
||||
Swal.fire({icon: "warning", title: "Belum lengkap", text: "Harap masukkan " + (label[searchBy] || "kata kunci")});
|
||||
|
||||
$("#search-value").focus();
|
||||
|
||||
@@ -146,7 +165,6 @@ $(document).ready(function () {
|
||||
});
|
||||
});
|
||||
} else {
|
||||
alert("Data tidak ditemukan.");
|
||||
$("#example tbody").html(
|
||||
`<tr>
|
||||
<td colspan="11" style="text-align: center;"><p class="text-danger mt-3">Tidak ditemukan data</p></td>
|
||||
@@ -154,6 +172,17 @@ $(document).ready(function () {
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
let msg = "Gagal memuat data.";
|
||||
if (xhr.status === 422 && xhr.responseJSON?.message) msg = xhr.responseJSON.message;
|
||||
$("#example tbody").html(
|
||||
`<tr><td colspan="11" class="text-center text-danger py-4">${msg}</td></tr>`,
|
||||
);
|
||||
Swal.fire({icon: "error", title: "Pencarian gagal", text: msg});
|
||||
},
|
||||
complete: function () {
|
||||
$("#search-button").prop("disabled", false).html('<i class="fa fa-search me-2"></i> Cari Data...');
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user