$(function(){var a,e=$(".invoice-list-table");e.length&&(a=e.DataTable({ajax:assetsPath+"json/invoice-list.json",columns:[{data:"invoice_id"},{data:"invoice_id"},{data:"invoice_id"},{data:"invoice_status"},{data:"issued_date"},{data:"client_name"},{data:"total"},{data:"balance"},{data:"invoice_status"},{data:"action"}],columnDefs:[{className:"control",responsivePriority:2,searchable:!1,targets:0,render:function(a,e,t,s){return""}},{targets:1,orderable:!1,checkboxes:{selectAllRender:''},render:function(){return''},searchable:!1},{targets:2,render:function(a,e,t,s){return'#'+t.invoice_id+""}},{targets:3,render:function(a,e,t,s){var n=t.invoice_status,l=t.due_date;return" Balance: '+t.balance+'
Due Date: '+l+"'>"+{Sent:'',Draft:'',"Past Due":'',"Partial Payment":'',Paid:'',Downloaded:''}[n]+""}},{targets:4,responsivePriority:4,render:function(a,e,t,s){var n=t.client_name,l=t.service,i=t.avatar_image,o=Math.floor(11*Math.random())+1;return'
'+(!0===i?'

':'
'+(i=(((i=(n=t.client_name).match(/\b\w/g)||[]).shift()||"")+(i.pop()||"")).toUpperCase())+"")+'
"}},{targets:5,render:function(a,e,t,s){t=t.total;return''+t+"$"+t}},{targets:6,render:function(a,e,t,s){t=new Date(t.due_date);return''+moment(t).format("YYYYMMDD")+""+moment(t).format("DD MMM YYYY")}},{targets:7,orderable:!1,render:function(a,e,t,s){t=t.balance;return 0===t?' Paid ':''+t+''+t+""}},{targets:8,visible:!1},{targets:-1,title:"Actions",searchable:!1,orderable:!1,render:function(a,e,t,s){return''}}],order:[[2,"desc"]],dom:'<"row"<"col-12 col-md-6 d-flex align-items-center justify-content-center justify-content-md-start gap-2"l<"dt-action-buttons text-xl-end text-lg-start text-md-end text-start"B>><"col-12 col-md-6 d-flex align-items-center justify-content-end flex-column flex-md-row gap-md-4 mt-n6 mt-md-0"f<"invoice_status mb-6 mb-md-0">>>t<"row"<"col-sm-12 col-md-6"i><"col-sm-12 col-md-6"p>>',language:{sLengthMenu:"Show _MENU_",search:"",searchPlaceholder:"Search Invoice",paginate:{next:'
',previous:'
'}},buttons:[{text:'
Create Invoice',className:"btn btn-primary",action:function(a,e,t,s){window.location="app-invoice-add.html"}}],responsive:{details:{display:$.fn.dataTable.Responsive.display.modal({header:function(a){return"Details of "+a.data().full_name}}),type:"column",renderer:function(a,e,t){t=$.map(t,function(a,e){return""!==a.title?'
| '+a.title+": | "+a.data+" |
":""}).join("");return!!t&&$('
').append(t)}}},initComplete:function(){this.api().columns(8).every(function(){var e=this,t=$('
').appendTo(".invoice_status").on("change",function(){var a=$.fn.dataTable.util.escapeRegex($(this).val());e.search(a?"^"+a+"$":"",!0,!1).draw()});e.data().unique().sort().each(function(a,e){t.append('
")})})}})),e.on("draw.dt",function(){[].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')).map(function(a){return new bootstrap.Tooltip(a,{boundary:document.body})})}),$(".invoice-list-table tbody").on("click",".delete-record",function(){a.row($(this).parents("tr")).remove().draw()}),setTimeout(()=>{$(".dataTables_filter .form-control").removeClass("form-control-sm"),$(".dataTables_length .form-select").removeClass("form-select-sm")},300)});