HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/video-rental/wp-content/themes/video-rental-olds/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);
                    });
                };
            });
    });
});