Fully Migrated Quote and Invoice to use TCPDF and elimiated PDFMake
This commit is contained in:
@@ -168,7 +168,9 @@ if ($balance > 0) {
|
||||
<div class="col-6">
|
||||
<div class="float-right">
|
||||
<a class="btn btn-default" href="#" onclick="window.print();"><i class="fas fa-fw fa-print mr-2"></i>Print</a>
|
||||
<a class="btn btn-default" href="#" onclick="pdfMake.createPdf(docDefinition).download('<?php echo strtoAZaz09(html_entity_decode("$invoice_date-$company_name-Invoice-$invoice_prefix$invoice_number")); ?>');"><i class="fa fa-fw fa-download mr-2"></i>Download</a>
|
||||
<a class="btn btn-default" href="guest_post.php?export_invoice_pdf=<?php echo $invoice_id; ?>&url_key=<?php echo $url_key; ?>">
|
||||
<i class="fa fa-fw fa-download mr-2"></i>Download
|
||||
</a>
|
||||
<?php
|
||||
if ($invoice_status !== "Paid" && $invoice_status !== "Cancelled" && $invoice_status !== "Draft" && $config_stripe_enable == 1) { ?>
|
||||
<a class="btn btn-success" href="guest_pay_invoice_stripe.php?invoice_id=<?php echo $invoice_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-credit-card mr-2"></i>Pay Now </a>
|
||||
@@ -180,10 +182,12 @@ if ($balance > 0) {
|
||||
<div class="card-body">
|
||||
|
||||
<div class="row mb-3">
|
||||
<?php if (file_exists("../uploads/settings/$company_logo")) { ?>
|
||||
<div class="col-sm-2">
|
||||
<img class="img-fluid" src="<?php echo "../uploads/settings/$company_logo"; ?>" alt="Company logo">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<?php } ?>
|
||||
<div class="col-sm-6 <?php if (!file_exists("../uploads/settings/$company_logo")) { echo "col-sm-8"; } ?>">
|
||||
<ul class="list-unstyled">
|
||||
<li><h4><strong><?php echo $company_name; ?></strong></h4></li>
|
||||
<li><?php echo $company_address; ?></li>
|
||||
@@ -343,473 +347,6 @@ if ($balance > 0) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src='../plugins/pdfmake/pdfmake.min.js'></script>
|
||||
<script src='../plugins/pdfmake/vfs_fonts.js'></script>
|
||||
<script>
|
||||
|
||||
var docDefinition = {
|
||||
info: {
|
||||
title: <?php echo json_encode(html_entity_decode($company_name) . "- Invoice") ?>,
|
||||
author: <?php echo json_encode(html_entity_decode($company_name)) ?>
|
||||
},
|
||||
|
||||
//watermark: {text: '<?php echo $invoice_status; ?>', color: 'lightgrey', opacity: 0.3, bold: true, italics: false},
|
||||
|
||||
content: [
|
||||
// Header
|
||||
{
|
||||
columns: [
|
||||
<?php if (!empty($company_logo_base64)) { ?>
|
||||
{
|
||||
image: <?php echo json_encode("data:image;base64,$company_logo_base64") ?>,
|
||||
width: 120
|
||||
},
|
||||
<?php } ?>
|
||||
|
||||
[
|
||||
{
|
||||
text: 'Invoice',
|
||||
style: 'invoiceTitle',
|
||||
width: '*'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(html_entity_decode("$invoice_prefix$invoice_number")) ?>,
|
||||
style: 'invoiceNumber',
|
||||
width: '*'
|
||||
},
|
||||
<?php if ($invoice_status == "Paid") { ?>
|
||||
{
|
||||
text: 'PAID',
|
||||
style: 'invoicePaid',
|
||||
width: '*'
|
||||
},
|
||||
<?php } ?>
|
||||
],
|
||||
],
|
||||
},
|
||||
// Billing Headers
|
||||
{
|
||||
columns: [
|
||||
{
|
||||
text: <?php echo json_encode(html_entity_decode($company_name)) ?>,
|
||||
style: 'invoiceBillingTitle',
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(html_entity_decode($client_name)) ?>,
|
||||
style: 'invoiceBillingTitleClient',
|
||||
},
|
||||
]
|
||||
},
|
||||
// Billing Address
|
||||
{
|
||||
columns: [
|
||||
{
|
||||
text: <?php echo json_encode(html_entity_decode("$company_address \n $company_city $company_state $company_zip \n $company_country \n $company_phone \n $company_website \n $company_tax_id_display")) ?>,
|
||||
style: 'invoiceBillingAddress'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(html_entity_decode("$location_address \n $location_city $location_state $location_zip \n $location_country \n $contact_email \n $contact_phone")) ?>,
|
||||
style: 'invoiceBillingAddressClient'
|
||||
},
|
||||
]
|
||||
},
|
||||
//Invoice Dates Table
|
||||
{
|
||||
table: {
|
||||
// headers are automatically repeated if the table spans over multiple pages
|
||||
// you can declare how many rows should be treated as headers
|
||||
headerRows: 0,
|
||||
widths: [ '*',80, 80 ],
|
||||
|
||||
body: [
|
||||
// Total
|
||||
[
|
||||
{
|
||||
text: '',
|
||||
rowSpan: 3
|
||||
},
|
||||
{},
|
||||
{},
|
||||
],
|
||||
[
|
||||
{},
|
||||
{
|
||||
text: 'Date',
|
||||
style: 'invoiceDateTitle'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(html_entity_decode($invoice_date)) ?>,
|
||||
style: 'invoiceDateValue'
|
||||
},
|
||||
],
|
||||
[
|
||||
{},
|
||||
{
|
||||
text: 'Due',
|
||||
style: 'invoiceDueDateTitle'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(html_entity_decode($invoice_due)) ?>,
|
||||
style: 'invoiceDueDateValue'
|
||||
},
|
||||
],
|
||||
]
|
||||
}, // table
|
||||
layout: 'lightHorizontalLines'
|
||||
},
|
||||
// Line breaks
|
||||
'\n\n',
|
||||
// Items
|
||||
{
|
||||
table: {
|
||||
// headers are automatically repeated if the table spans over multiple pages
|
||||
// you can declare how many rows should be treated as headers
|
||||
headerRows: 1,
|
||||
widths: [ '*', 40, 'auto', 'auto', 80 ],
|
||||
|
||||
body: [
|
||||
// Table Header
|
||||
[
|
||||
{
|
||||
text: 'Product',
|
||||
style: [ 'itemsHeader', 'left']
|
||||
},
|
||||
{
|
||||
text: 'Qty',
|
||||
style: [ 'itemsHeader', 'center']
|
||||
},
|
||||
{
|
||||
text: 'Price',
|
||||
style: [ 'itemsHeader', 'right']
|
||||
},
|
||||
{
|
||||
text: 'Tax',
|
||||
style: [ 'itemsHeader', 'right']
|
||||
},
|
||||
{
|
||||
text: 'Total',
|
||||
style: [ 'itemsHeader', 'right']
|
||||
}
|
||||
],
|
||||
// Items
|
||||
<?php
|
||||
$total_tax = 0;
|
||||
$sub_total = 0;
|
||||
|
||||
$sql_invoice_items = mysqli_query($mysqli, "SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id ORDER BY item_order ASC");
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_invoice_items)) {
|
||||
$item_name = $row['item_name'];
|
||||
$item_description = $row['item_description'];
|
||||
$item_quantity = $row['item_quantity'];
|
||||
$item_price = $row['item_price'];
|
||||
$item_subtotal = $row['item_price'];
|
||||
$item_tax = $row['item_tax'];
|
||||
$item_total = $row['item_total'];
|
||||
$tax_id = $row['item_tax_id'];
|
||||
$total_tax = $item_tax + $total_tax;
|
||||
$sub_total = $item_price * $item_quantity + $sub_total;
|
||||
?>
|
||||
|
||||
// Item
|
||||
[
|
||||
[
|
||||
{
|
||||
text: <?php echo json_encode($item_name) ?>,
|
||||
style:'itemTitle'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode($item_description) ?>,
|
||||
style:'itemDescription'
|
||||
}
|
||||
],
|
||||
{
|
||||
text: <?php echo json_encode($item_quantity) ?>,
|
||||
style: 'itemQty'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(numfmt_format_currency($currency_format, $item_price, $invoice_currency_code)) ?>,
|
||||
style: 'itemNumber'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(numfmt_format_currency($currency_format, $item_tax, $invoice_currency_code)) ?>,
|
||||
style: 'itemNumber'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(numfmt_format_currency($currency_format, $item_total, $invoice_currency_code)) ?>,
|
||||
style: 'itemNumber'
|
||||
}
|
||||
],
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
// END Items
|
||||
]
|
||||
}, // table
|
||||
layout: 'lightHorizontalLines'
|
||||
},
|
||||
// TOTAL
|
||||
{
|
||||
table: {
|
||||
// headers are automatically repeated if the table spans over multiple pages
|
||||
// you can declare how many rows should be treated as headers
|
||||
headerRows: 0,
|
||||
widths: [ '*','auto', 80 ],
|
||||
|
||||
body: [
|
||||
// Total
|
||||
[
|
||||
{
|
||||
text: 'Notes',
|
||||
style: 'notesTitle'
|
||||
},
|
||||
{},
|
||||
{}
|
||||
],
|
||||
[
|
||||
{
|
||||
rowSpan: '*',
|
||||
text: <?php echo json_encode(html_entity_decode($invoice_note)) ?>,
|
||||
style: 'notesText'
|
||||
},
|
||||
{
|
||||
text: 'Subtotal',
|
||||
style: 'itemsFooterSubTitle'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(numfmt_format_currency($currency_format, $sub_total, $invoice_currency_code)) ?>,
|
||||
style: 'itemsFooterSubValue'
|
||||
}
|
||||
],
|
||||
<?php if ($invoice_discount > 0) { ?>
|
||||
[
|
||||
{},
|
||||
{
|
||||
text: 'Discount',
|
||||
style: 'itemsFooterSubTitle'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(numfmt_format_currency($currency_format, -$invoice_discount, $invoice_currency_code)) ?>,
|
||||
style: 'itemsFooterSubValue'
|
||||
}
|
||||
],
|
||||
<?php } ?>
|
||||
<?php if ($total_tax > 0) { ?>
|
||||
[
|
||||
{},
|
||||
{
|
||||
text: 'Tax',
|
||||
style: 'itemsFooterSubTitle'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(numfmt_format_currency($currency_format, $total_tax, $invoice_currency_code)) ?>,
|
||||
style: 'itemsFooterSubValue'
|
||||
}
|
||||
],
|
||||
<?php } ?>
|
||||
[
|
||||
{},
|
||||
{
|
||||
text: 'Total',
|
||||
style: 'itemsFooterSubTitle'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code)) ?>,
|
||||
style: 'itemsFooterSubValue'
|
||||
}
|
||||
],
|
||||
<?php if ($amount_paid > 0) { ?>
|
||||
[
|
||||
{},
|
||||
{
|
||||
text: 'Paid',
|
||||
style: 'itemsFooterSubTitle'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(numfmt_format_currency($currency_format, $amount_paid, $invoice_currency_code)) ?>,
|
||||
style: 'itemsFooterSubValue'
|
||||
}
|
||||
],
|
||||
<?php } ?>
|
||||
[
|
||||
{},
|
||||
{
|
||||
text: 'Balance',
|
||||
style: 'itemsFooterTotalTitle'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode(numfmt_format_currency($currency_format, $balance, $invoice_currency_code)) ?>,
|
||||
|
||||
style: 'itemsFooterTotalTitle'
|
||||
}
|
||||
],
|
||||
]
|
||||
}, // table
|
||||
layout: 'lightHorizontalLines'
|
||||
},
|
||||
// TERMS / FOOTER
|
||||
{
|
||||
text: <?php echo json_encode(html_entity_decode($config_invoice_footer)) ?>,
|
||||
style: 'documentFooterCenter'
|
||||
}
|
||||
], //End Content,
|
||||
styles: {
|
||||
// Document Footer
|
||||
documentFooterCenter: {
|
||||
fontSize: 9,
|
||||
margin: [10,50,10,10],
|
||||
alignment: 'center'
|
||||
},
|
||||
// Invoice Title
|
||||
invoiceTitle: {
|
||||
fontSize: 18,
|
||||
bold: true,
|
||||
alignment: 'right',
|
||||
margin: [0,0,0,3]
|
||||
},
|
||||
// Invoice Number
|
||||
invoiceNumber: {
|
||||
fontSize: 14,
|
||||
alignment: 'right'
|
||||
},
|
||||
// Invoice Paid
|
||||
invoicePaid: {
|
||||
fontSize: 13,
|
||||
bold: true,
|
||||
margin: [0,5,0,0],
|
||||
alignment: 'right',
|
||||
color: 'green'
|
||||
},
|
||||
// Billing Headers
|
||||
invoiceBillingTitle: {
|
||||
fontSize: 14,
|
||||
bold: true,
|
||||
alignment: 'left',
|
||||
margin: [0,20,0,5]
|
||||
},
|
||||
invoiceBillingTitleClient: {
|
||||
fontSize: 14,
|
||||
bold: true,
|
||||
alignment: 'right',
|
||||
margin: [0,20,0,5]
|
||||
},
|
||||
// Billing Details
|
||||
invoiceBillingAddress: {
|
||||
fontSize: 10,
|
||||
lineHeight: 1.2
|
||||
},
|
||||
invoiceBillingAddressClient: {
|
||||
fontSize: 10,
|
||||
lineHeight: 1.2,
|
||||
alignment: 'right',
|
||||
margin: [0,0,0,30]
|
||||
},
|
||||
// Invoice Date
|
||||
invoiceDateTitle: {
|
||||
fontSize: 10,
|
||||
alignment: 'left',
|
||||
margin: [0,5,0,5]
|
||||
},
|
||||
invoiceDateValue: {
|
||||
fontSize: 10,
|
||||
alignment: 'right',
|
||||
margin: [0,5,0,5]
|
||||
},
|
||||
// Invoice Due Date
|
||||
invoiceDueDateTitle: {
|
||||
fontSize: 10,
|
||||
bold: true,
|
||||
alignment: 'left',
|
||||
margin: [0,5,0,5]
|
||||
},
|
||||
invoiceDueDateValue: {
|
||||
fontSize: 10,
|
||||
bold: true,
|
||||
alignment: 'right',
|
||||
margin: [0,5,0,5]
|
||||
},
|
||||
// Items Header
|
||||
itemsHeader: {
|
||||
fontSize: 10,
|
||||
margin: [0,5,0,5],
|
||||
bold: true,
|
||||
alignment: 'right'
|
||||
},
|
||||
// Item Title
|
||||
itemTitle: {
|
||||
fontSize: 10,
|
||||
bold: true,
|
||||
margin: [0,5,0,3]
|
||||
},
|
||||
itemDescription: {
|
||||
italics: true,
|
||||
fontSize: 9,
|
||||
lineHeight: 1.1,
|
||||
margin: [0,3,0,5]
|
||||
},
|
||||
itemQty: {
|
||||
fontSize: 10,
|
||||
margin: [0,5,0,5],
|
||||
alignment: 'center'
|
||||
},
|
||||
itemNumber: {
|
||||
fontSize: 10,
|
||||
margin: [0,5,0,5],
|
||||
alignment: 'right'
|
||||
},
|
||||
itemTotal: {
|
||||
fontSize: 10,
|
||||
margin: [0,5,0,5],
|
||||
bold: true,
|
||||
alignment: 'right'
|
||||
},
|
||||
// Items Footer (Subtotal, Total, Tax, etc)
|
||||
itemsFooterSubTitle: {
|
||||
fontSize: 10,
|
||||
margin: [0,5,0,5],
|
||||
alignment: 'right'
|
||||
},
|
||||
itemsFooterSubValue: {
|
||||
fontSize: 10,
|
||||
margin: [0,5,0,5],
|
||||
bold: false,
|
||||
alignment: 'right'
|
||||
},
|
||||
itemsFooterTotalTitle: {
|
||||
fontSize: 10,
|
||||
margin: [0,5,0,5],
|
||||
bold: true,
|
||||
alignment: 'right'
|
||||
},
|
||||
itemsFooterTotalValue: {
|
||||
fontSize: 10,
|
||||
margin: [0,5,0,5],
|
||||
bold: true,
|
||||
alignment: 'right'
|
||||
},
|
||||
notesTitle: {
|
||||
fontSize: 10,
|
||||
bold: true,
|
||||
margin: [0,5,0,5]
|
||||
},
|
||||
notesText: {
|
||||
fontSize: 9,
|
||||
margin: [0,5,50,5]
|
||||
},
|
||||
left: {
|
||||
alignment: 'left'
|
||||
},
|
||||
center: {
|
||||
alignment: 'center'
|
||||
},
|
||||
},
|
||||
defaultStyle: {
|
||||
columnGap: 20
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
// CURRENT INVOICES
|
||||
|
||||
Reference in New Issue
Block a user