"use strict";$(function(){var a,e=$(".invoice-list-table");e.length&&(a=e.DataTable({ajax:assetsPath+"json/invoice-list.json",columns:[{data:""},{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,render:function(a,e,t,s){return'#'+t.invoice_id+""}},{targets:2,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:3,responsivePriority:4,render:function(a,e,t,s){var n=t.client_name,l=t.service,r=t.avatar_image,i=Math.floor(11*Math.random())+1;return'
'+(!0===r?'Avatar':''+(r=(((r=(n=t.client_name).match(/\b\w/g)||[]).shift()||"")+(r.pop()||"")).toUpperCase())+"")+'
'+n+''+l+"
"}},{targets:4,render:function(a,e,t,s){t=t.total;return''+t+"$"+t}},{targets:5,render:function(a,e,t,s){t=new Date(t.due_date);return''+moment(t).format("YYYYMMDD")+""+moment(t).format("DD MMM YYYY")}},{targets:6,orderable:!1,render:function(a,e,t,s){t=t.balance;return 0===t?' Paid ':''+t+""+t}},{targets:7,visible:!1},{targets:-1,title:"Actions",searchable:!1,orderable:!1,render:function(a,e,t,s){return'
'}}],order:[[1,"desc"]],dom:'<"row mx-1"<"col-12 col-md-6 d-flex align-items-center justify-content-center justify-content-md-start gap-3"l<"dt-action-buttons text-xl-end text-lg-start text-md-end text-start mt-md-0 mt-3"B>><"col-12 col-md-6 d-flex align-items-center justify-content-end flex-column flex-md-row pe-3 gap-md-3"f<"invoice_status mb-3 mb-md-0">>>t<"row mx-2"<"col-sm-12 col-md-6"i><"col-sm-12 col-md-6"p>>',language:{sLengthMenu:"_MENU_",search:"",searchPlaceholder:"Search Invoice"},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(7).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)});