| 1 |
<?php |
| 2 |
// Enqueue PDF scripts |
| 3 |
EasyInvoice\Includes\Helpers\PdfHelper::enqueuePdfScripts(); |
| 4 |
?> |
| 5 |
|
| 6 |
<div class="wrap"> |
| 7 |
<h1>Invoice #<?php echo esc_html($invoice->getNumber()); ?></h1> |
| 8 |
|
| 9 |
<div class="invoice-actions"> |
| 10 |
<button type="button" class="button button-primary" id="generate-pdf"> |
| 11 |
Download PDF |
| 12 |
</button> |
| 13 |
</div> |
| 14 |
|
| 15 |
</div> |
| 16 |
|
| 17 |
<script> |
| 18 |
document.addEventListener('DOMContentLoaded', function() { |
| 19 |
const generatePdfButton = document.getElementById('generate-pdf'); |
| 20 |
|
| 21 |
generatePdfButton.addEventListener('click', function() { |
| 22 |
// Use the new PDF generator that captures HTML directly |
| 23 |
if (typeof InvoicePdfGenerator !== 'undefined') { |
| 24 |
const pdfGenerator = new InvoicePdfGenerator(); |
| 25 |
pdfGenerator.generatePDF(); |
| 26 |
} else { |
| 27 |
alert('PDF generator not available'); |
| 28 |
} |
| 29 |
}); |
| 30 |
}); |
| 31 |
</script> |