This commit is contained in:
Pinga 2023-11-09 11:40:16 +02:00
parent 164b54994c
commit 0bf5eda72c
10 changed files with 261 additions and 692 deletions

View file

@ -6,30 +6,48 @@
<script>
var table;
document.addEventListener("DOMContentLoaded", function(){
table = new Tabulator("#overviewTable", {
ajaxURL:"/api/records/payment_history", // Set the URL for your JSON data
ajaxURL:"/api/records/payment_history?join=registrar", // Set the URL for your JSON data
ajaxConfig:"GET",
pagination:"local",
paginationSize:10,
ajaxResponse:function(url, params, response){
return response.records;
},
layout:"fitColumns",
responsiveLayout: "hide",
layout:"fitDataFill",
responsiveLayout: "collapse",
responsiveLayoutCollapseStartOpen:false,
resizableColumns:false,
initialSort:[
{column:"date", dir:"desc"},
],
columns:[
{title:"Registrar", field:"registrar_id", headerSort:true},
{title:"Date", field:"date", headerSort:true, responsive:0},
{title:"Description", field:"description", headerSort:true, responsive:0},
{title:"Amount", field:"amount", headerSort:true, download:false},
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
{title:"Registrar", field:"registrar_id.name", headerSort:true, responsive:0},
{title:"Date", field:"date", headerSort:true, responsive:2},
{title:"Description", field:"description", headerSort:true, responsive:2},
{title:"Amount", field:"amount", headerSort:true, download:false, responsive:0},
],
});
var searchInput = document.getElementById("search-input");
searchInput.addEventListener("input", function(){
table.setFilter("description", "like", searchInput.value);
});
searchInput.addEventListener("input", function () {
var term = searchInput.value.toLowerCase();
if (term) { // Only apply the filter when there's a term to search for
table.setFilter(function (data) {
// Check if any of the fields contain the search term
return (
String(data.registrar_id.name).toLowerCase().includes(term) ||
String(data.date).toLowerCase().includes(term) ||
String(data.description).toLowerCase().includes(term) ||
String(data.amount).toString().toLowerCase().includes(term)
);
});
} else {
table.clearFilter(); // Clear the filter when the search box is emptied
}
});
});
function downloadCSV() {