StocksNew/public/assets/js/pages/invoiceslist.init.js

41 lines
47 KiB
JavaScript
Raw Normal View History

2024-08-27 12:03:06 +00:00
function getTime(e){if(null!=(e=new Date(e)).getHours())return e.getHours()+":"+(e.getMinutes()?e.getMinutes():0)}function tConvert(e){var e=new Date(e),e=(time_s=e.getHours()+":"+e.getMinutes()).split(":"),t=e[0],e=e[1],a=12<=t?"PM":"AM";return(t=(t%=12)||12)+":"+(e<10?"0"+e:e)+" "+a}var invoice_new_obj,str_dt=function(e){var e=new Date(e),t=""+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],a=""+e.getDate(),e=e.getFullYear();return t.length<2&&(t="0"+t),[(a=a.length<2?"0"+a:a)+" "+t,e].join(", ")},date=new Date,d=date.getDate(),m=date.getMonth(),y=date.getFullYear(),qty=0,rate=0,Invoices=[{invoice_no:"25000351",customer:"Valentine Morin",img:"avatar-1.jpg",email:"euismod.enim@outlook.net",date:new Date(2021,3,d-23,21,58),invoice_amount:875,status:"Paid",billing_address:{full_name:"Valentine Morin",address:"5114 Adipiscing St. Puno United States 46782",phone:"(926) 817-7835",tax:"123456789"},shipping_address:{full_name:"Quamar Payne",address:"534-1477 Non, Av. Bury St. Edmunds France 10846",phone:"(926) 817-7835",tax:"123456789"},prducts:[{product_name:"Sweatshirt for Men (Pink)",product_details:"Graphic Print Men & Women Sweatshirt",rates:rate=119.99,quantity:qty=2,amount:rate*qty},{product_name:"Noise NoiseFit Endure Smart Watch",product_details:"32.5mm (1.28 Inch) TFT Color Touch Display",rates:rate=94.99,quantity:qty=1,amount:rate*qty},{product_name:"350 ml Glass Grocery Container",product_details:"Glass Grocery Container (Pack of 3, White)",rates:rate=24.99,quantity:qty=1,amount:rate*qty}],payment_details:{payment_method:"VISA",card_holder_name:"Reese Jacobs",card_number:"4024007179348742",total_amount:415.96},company_details:{legal_registration_no:"987654",email:"velzon@themesbrand.com",website:"www.themesbrand.com",contact_no:"0123456789",address:"California, United States",zip_code:"90201"},order_summary:{sub_total:359.96,estimated_tex:44.99,discount:53.99,shipping_charge:65,total_amount:415.96},notes:"All accounts are to be paid within 7 days from receipt of invoice. To be paid by cheque or credit card or direct payment online. If account is not paid within 7 days the credits details supplied as confirmation of work undertaken will be charged the agreed quoted fee noted above."},{invoice_no:"25000352",customer:"Brody Holman",img:"avatar-2.jpg",email:"metus@protonmail.org",date:new Date(2021,5,d-23,21,58),invoice_amount:875,status:"Unpaid",billing_address:{full_name:"Brody Holman",address:"P.O. Box 900 Ireland, 6694 Ullamcorper Avenue Port Pirie 37176",phone:"1-862-423-3347",tax:"123456789"},shipping_address:{full_name:"Elijah Galloway",address:"7288 Dignissim Rd. Villa Alegre Germany 891315",phone:"1-862-423-3347",tax:"123456789"},prducts:[{product_name:"Sweatshirt for Men (Pink)",product_details:"Graphic Print Men & Women Sweatshirt",rates:rate=119.99,quantity:qty=2,amount:rate*qty},{product_name:"Noise NoiseFit Endure Smart Watch",product_details:"32.5mm (1.28 Inch) TFT Color Touch Display",rates:rate=94.99,quantity:qty=1,amount:rate*qty},{product_name:"350 ml Glass Grocery Container",product_details:"Glass Grocery Container (Pack of 3, White)",rates:rate=24.99,quantity:qty=1,amount:rate*qty}],payment_details:{payment_method:"VISA",card_holder_name:"Rashawn Kuhn",card_number:"4916669499578927",total_amount:415.96},company_details:{legal_registration_no:"987654",email:"velzon@themesbrand.com",website:"www.themesbrand.com",contact_no:"0123456789",address:"California, United States",zip_code:"90201"},order_summary:{sub_total:359.96,estimated_tex:44.99,discount:53.99,shipping_charge:65,total_amount:415.96},notes:"All accounts are to be paid within 7 days from receipt of invoice. To be paid by cheque or credit card or direct payment online. If account is not paid within 7 days the credits details supplied as confirmation of work undertaken will be charged the agreed quoted fee noted above."},{invoice_no:"25000353",customer:"Jolie Hood",img:"avatar-3.jpg",email:"nunc.nulla@yahoo.edu",date:new Date(2021,3,d-23,21,58),invoice_amount:875,status:"Paid",billing_address:{full_name
<th scope="row">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="chk_child" value="#VL${e.invoice_no}">
</div>
</th>
<td class="id"><a href="javascript:void(0);" onclick="ViewInvoice(this);" data-id="`+e.invoice_no+'" class="fw-medium link-primary">#VL'+e.invoice_no+`</a></td>
<td class="customer_name">
<div class="d-flex align-items-center">
`+a+e.customer+`
</div>
</td>
<td class="email">`+e.email+`</td>
<td class="country">USA</td>
<td class="date">`+str_dt(e.date)+' <small class="text-muted">'+tConvert(e.date)+`</small></td>
<td class="invoice_amount">$`+e.invoice_amount+`</td>
<td class="status"><span class="badge bg-`+t+"-subtle text-"+t+' text-uppercase">'+e.status+`</span>
</td>
<td>
<div class="dropdown">
<button class="btn btn-soft-secondary btn-sm dropdown" type="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="ri-more-fill align-middle"></i>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li><button class="dropdown-item" href="javascript:void(0);" onclick="ViewInvoice(this);" data-id="`+e.invoice_no+`" ><i class="ri-eye-fill align-bottom me-2 text-muted"></i>
View</button></li>
<li><button class="dropdown-item" href="javascript:void(0);" onclick="EditInvoice(this);" data-id="`+e.invoice_no+`"><i class="ri-pencil-fill align-bottom me-2 text-muted"></i>
Edit</button></li>
<li><a class="dropdown-item" href="javascript:void(0);"><i class="ri-download-2-line align-bottom me-2 text-muted"></i>
Download</a></li>
<li class="dropdown-divider"></li>
<li>
<a class="dropdown-item remove-item-btn" data-bs-toggle="modal" href="#deleteOrder">
<i class="ri-delete-bin-fill align-bottom me-2 text-muted"></i>
Delete
</a>
</li>
</ul>
</div>
</td>
</tr>`;document.getElementById("invoice-list-data").innerHTML+=a}),document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll('[data-plugin="choices"]');Array.from(e).forEach(function(e){new Choices(e,{placeholderValue:"This is a placeholder set in the config",searchPlaceholderValue:"Search results here"})})}),flatpickr("#datepicker-range",{mode:"range",dateFormat:"d M, Y"}),flatpickr("#date-field",{dateFormat:"d M, Y"}),document.getElementById("checkAll")),perPage=(checkAll&&(checkAll.onclick=function(){for(var e=document.querySelectorAll('.form-check-all input[type="checkbox"]'),t=document.querySelectorAll('.form-check-all input[type="checkbox"]:checked').length,a=0;a<e.length;a++)e[a].checked=this.checked,e[a].checked?e[a].closest("tr").classList.add("table-active"):e[a].closest("tr").classList.remove("table-active");document.getElementById("remove-actions").style.display=0<t?"none":"block"}),8),options={valueNames:["id","customer_name","email","country","date","invoice_amount","status"],page:perPage,pagination:!0,plugins:[ListPagination({left:2,right:2})]},invoiceList=new List("invoiceList",options).on("updated",function(e){0==e.matchingItems.length?document.getElementsByClassName("noresult")[0].style.display="block":document.getElementsByClassName("noresult")[0].style.display="none";var t=1==e.i,a=e.i>e.matchingItems.length-e.page;document.querySelector(".pagination-prev.disabled")&&document.querySelector(".pagination-prev.disabled").classList.remove("disabled"),document.querySelector(".pagination-next.disabled")&&document.querySelector(".pagination-next.disabled").classList.remove("disabled"),t&&document.querySelector(".pagination-prev").classList.add("disabled"),a&&document.querySelector(".pagination-next").classList.add("disabled"),e.matchingItems.length<=perPage?document.querySelector(".pagination-wrap").style.display="none":document.querySelector(".pagination-wrap").style.display="flex",e.matchingItems.length==perPage&&document.querySelector(".pagination.listjs-pagination").firstElementChild.children[0].click(),0<e.matchingItems.length?document.getElementsByClassName("noresult")[0].style.display="none":document.getElementsByClassName("noresult")[0].style.display="block"}),isValue=(isCount=(new DOMParser).parseFromString(invoiceList.items.slice(-1)[0]._values.id,"text/html")).body.firstElementChild.innerHTML,idField=document.getElementById("orderId"),customerNameField=document.getElementById("customername-field"),emailField=document.getElementById("email-field"),dateField=document.getElementById("date-field"),countryField=document.getElementById("country-field"),statusField=document.getElementById("delivered-status"),addBtn=document.getElementById("add-btn"),editBtn=document.getElementById("edit-btn"),removeBtns=document.getElementsByClassName("remove-item-btn"),editBtns=document.getElementsByClassName("edit-item-btn");function filterContact(e){var t=e;invoiceList.filter(function(e){e=(matchData=(new DOMParser).parseFromString(e.values().status,"text/html")).body.firstElementChild.innerHTML;return"All"==e||"All"==t||e==t}),invoiceList.update()}function updateList(){var t=document.querySelector("input[name=status]:checked").value;data=userList.filter(function(e){return"All"==t||e.values().sts==t}),userList.update()}refreshCallbacks(),filterContact("All");var table=document.getElementById("invoiceTable"),tr=table.getElementsByTagName("tr"),trlist=table.querySelectorAll(".list tr");function SearchData(){var i=document.getElementById("idStatus").value,o=document.getElementById("datepicker-range").value,r=o.split(" to ")[0],s=o.split(" to ")[1];invoiceList.filter(function(e){var t=(matchData=(new DOMParser).parseFromString(e.values().status,"text/html")).body.firstElementChild.innerHTML,a=!1,n=!1,a="all"==t||"all"==i||t==i,n=new Date(e.values().date.slice(0,12))>=new Date(r)&&new Date(e.values().date.slice(0,12))<=new Date(s);return a&&n||(a&&""==o?a:n&&""==o?n:void 0)}),invoiceList.update()}function ischeckboxcheck(){Array.from(document.getElementsByName("chk_child")).forEac