File: /var/www/html/video-rental/wp-content/themes/video-rental-old/js/download-invoice.js
jQuery(document).ready(function($) {
$('.download-invoice-btn').on('click', function() {
let code = $(this).data('code');
let invoiceUrl = download_invoice_vars.invoice_template_url + '?code=' + code;
fetch(invoiceUrl)
.then(res => res.text())
.then(html => {
let iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
iframe.contentDocument.open();
iframe.contentDocument.write(html);
iframe.contentDocument.close();
iframe.onload = function() {
html2pdf().from(iframe.contentDocument.body).set({
filename: 'affiliate-invoice-' + code + '.pdf',
margin: 0.5,
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' },
html2canvas: { scale: 2 }
}).save().then(() => {
document.body.removeChild(iframe);
});
};
});
});
});
jQuery(document).ready(function($) {
$('.download-invoice-btn-txn').on('click', function() {
let code = $(this).data('tid');
let invoiceUrl = download_invoice_vars.trans_invoice_template_url + '?transid=' + code;
// alert(invoiceUrl);
fetch(invoiceUrl)
.then(res => res.text())
.then(html => {
let iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
iframe.contentDocument.open();
iframe.contentDocument.write(html);
iframe.contentDocument.close();
iframe.onload = function() {
html2pdf().from(iframe.contentDocument.body).set({
filename: 'transaction-invoice-' + code + '.pdf',
margin: 0.5,
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' },
html2canvas: { scale: 2 }
}).save().then(() => {
document.body.removeChild(iframe);
});
};
});
});
});