var paymentSign="$";function otherPayment(){var e=document.getElementById("choices-payment-currency").value;paymentSign=e,document.getElementsByClassName("product-line-price").forEach(function(e){isUpdate=e.value.slice(1),e.value=paymentSign+isUpdate}),recalculateCart()}var isPaymentEl=document.getElementById("choices-payment-currency"),choices=new Choices(isPaymentEl,{searchEnabled:!1});function isData(){var e=document.getElementsByClassName("plus"),t=document.getElementsByClassName("minus");e&&e.forEach(function(n){n.onclick=function(e){var t;parseInt(n.previousElementSibling.value)<10&&(e.target.previousElementSibling.value++,t=n.parentElement.parentElement.previousElementSibling.querySelector(".product-price").value,e=n.parentElement.parentElement.nextElementSibling.querySelector(".product-line-price"),updateQuantity(n.parentElement.querySelector(".product-quantity").value,t,e))}}),t&&t.forEach(function(n){n.onclick=function(e){var t;1
Deletee.invoice_no===invoice_no),""!=viewobj&&"edit-invoice"==options){document.getElementById("registrationNumber").value=viewobj.company_details.legal_registration_no,document.getElementById("companyEmail").value=viewobj.company_details.email,document.getElementById("companyWebsite").value=viewobj.company_details.website,new Cleave("#compnayContactno",{prefix:viewobj.company_details.contact_no,delimiters:["(",")","-"],blocks:[0,3,3,4]}),document.getElementById("companyAddress").value=viewobj.company_details.address,document.getElementById("companyaddpostalcode").value=viewobj.company_details.zip_code;var preview=document.querySelectorAll(".user-profile-image");""!==viewobj.img&&(preview.src=viewobj.img),document.getElementById("invoicenoInput").value="#VAL"+viewobj.invoice_no,document.getElementById("invoicenoInput").setAttribute("readonly",!0),document.getElementById("date-field").value=viewobj.date,document.getElementById("choices-payment-status").value=viewobj.status,document.getElementById("totalamountInput").value="$"+viewobj.order_summary.total_amount,document.getElementById("billingName").value=viewobj.billing_address.full_name,document.getElementById("billingAddress").value=viewobj.billing_address.address,new Cleave("#billingPhoneno",{prefix:viewobj.company_details.contact_no,delimiters:["(",")","-"],blocks:[0,3,3,4]}),document.getElementById("billingTaxno").value=viewobj.billing_address.tax,document.getElementById("shippingName").value=viewobj.shipping_address.full_name,document.getElementById("shippingAddress").value=viewobj.shipping_address.address,new Cleave("#shippingPhoneno",{prefix:viewobj.company_details.contact_no,delimiters:["(",")","-"],blocks:[0,3,3,4]}),document.getElementById("shippingTaxno").value=viewobj.billing_address.tax;for(var paroducts_list=viewobj.prducts,counter=1;counter++,1=counter;);var counter_1=1;setTimeout(()=>{paroducts_list.forEach(function(e){document.getElementById("productName-"+counter_1).value=e.product_name,document.getElementById("productDetails-"+counter_1).value=e.product_details,document.getElementById("productRate-"+counter_1).value=e.rates,document.getElementById("product-qty-"+counter_1).value=e.quantity,document.getElementById("productPrice-"+counter_1).value="$"+e.rates*e.quantity,counter_1++})},300),document.getElementById("cart-subtotal").value="$"+viewobj.order_summary.sub_total,document.getElementById("cart-tax").value="$"+viewobj.order_summary.estimated_tex,document.getElementById("cart-discount").value="$"+viewobj.order_summary.discount,document.getElementById("cart-shipping").value="$"+viewobj.order_summary.shipping_charge,document.getElementById("cart-total").value="$"+viewobj.order_summary.total_amount,document.getElementById("choices-payment-type").value=viewobj.payment_details.payment_method,document.getElementById("cardholderName").value=viewobj.payment_details.card_holder_name;var cleave=new Cleave("#cardNumber",{prefix:viewobj.payment_details.card_number,delimiter:" ",blocks:[4,4,4,4],uppercase:!0});document.getElementById("amountTotalPay").value="$"+viewobj.order_summary.total_amount,document.getElementById("exampleFormControlTextarea1").value=viewobj.notes}document.addEventListener("DOMContentLoaded",function(){var P=document.getElementById("invoice_form");document.getElementsByClassName("needs-validation");P.addEventListener("submit",function(e){e.preventDefault();var t=document.getElementById("invoicenoInput").value.slice(4),n=document.getElementById("companyEmail").value,o=document.getElementById("date-field").value,a=document.getElementById("totalamountInput").value.slice(1),l=document.getElementById("choices-payment-status").value,i=document.getElementById("billingName").value,c=document.getElementById("billingAddress").value,d=document.getElementById("billingPhoneno").value.replace(/[^0-9]/g,""),u=document.getElementById("billingTaxno").value,r=document.getElementById("shippingName").value,m=document.getElementById("shippingAddress").value,s=document.getElementById("shippingPhoneno").value.replace(/[^0-9]/g,""),p=document.getElementById("shippingTaxno").value,v=document.getElementById("choices-payment-type").value,g=document.getElementById("cardholderName").value,y=document.getElementById("cardNumber").value.replace(/[^0-9]/g,""),E=document.getElementById("amountTotalPay").value.slice(1),b=document.getElementById("registrationNumber").value.replace(/[^0-9]/g,""),I=document.getElementById("companyEmail").value,h=document.getElementById("companyWebsite").value,_=document.getElementById("compnayContactno").value.replace(/[^0-9]/g,""),B=document.getElementById("companyAddress").value,f=document.getElementById("companyaddpostalcode").value,x=document.getElementById("cart-subtotal").value.slice(1),w=document.getElementById("cart-tax").value.slice(1),S=document.getElementById("cart-discount").value.slice(1),j=document.getElementById("cart-shipping").value.slice(1),q=document.getElementById("cart-total").value.slice(1),N=document.getElementById("exampleFormControlTextarea1").value,e=document.getElementsByClassName("product"),C=1,T=[];e.forEach(e=>{var t=e.querySelector("#productName-"+C).value,n=e.querySelector("#productDetails-"+C).value,o=parseInt(e.querySelector("#productRate-"+C).value),a=parseInt(e.querySelector("#product-qty-"+C).value),e=e.querySelector("#productPrice-"+C).value.split("$"),e={product_name:t,product_details:n,rates:rates=o,quantity:quantity=a,amount:amount=parseInt(e[1])};T.push(e),C++}),!1===P.checkValidity()?P.classList.add("was-validated"):("edit-invoice"==options&&invoice_no==t?(objIndex=invoices.findIndex(e=>e.invoice_no==t),invoices[objIndex].invoice_no=t,invoices[objIndex].customer=i,invoices[objIndex].img="",invoices[objIndex].email=n,invoices[objIndex].date=o,invoices[objIndex].invoice_amount=a,invoices[objIndex].status=l,invoices[objIndex].billing_address={full_name:i,address:c,phone:d,tax:u},invoices[objIndex].shipping_address={full_name:r,address:m,phone:s,tax:p},invoices[objIndex].payment_details={payment_method:v,card_holder_name:g,card_number:y,total_amount:E},invoices[objIndex].company_details={legal_registration_no:b,email:I,website:h,contact_no:_,address:B,zip_code:f},invoices[objIndex].order_summary={sub_total:x,estimated_tex:w,discount:S,shipping_charge:j,total_amount:q},invoices[objIndex].prducts=T,invoices[objIndex].notes=N,localStorage.removeItem("invoices-list"),localStorage.removeItem("option"),localStorage.removeItem("invoice_no"),localStorage.setItem("invoices-list",JSON.stringify(invoices))):localStorage.setItem("new_data_object",JSON.stringify({invoice_no:t,customer:i,img:"",email:n,date:o,invoice_amount:a,status:l,billing_address:{full_name:i,address:c,phone:d,tax:u},shipping_address:{full_name:r,address:m,phone:s,tax:p},payment_details:{payment_method:v,card_holder_name:g,card_number:y,total_amount:E},company_details:{legal_registration_no:b,email:I,website:h,contact_no:_,address:B,zip_code:f},order_summary:{sub_total:x,estimated_tex:w,discount:S,shipping_charge:j,total_amount:q},prducts:T,notes:N})),window.location.href="apps-invoices-list.html")})});