More Fixes to the Invoice PDF Template including escaping PHP Vars for Javascript using json_encode which was causing invoice pdf to break

This commit is contained in:
johnnyq
2021-04-06 19:07:48 -04:00
parent 72d379504b
commit a786fd7db5

View File

@@ -506,7 +506,10 @@ var docDefinition = {
}, },
footer: { footer: {
columns: [ columns: [
{ text: '<?php echo $config_invoice_footer; ?>', style: 'documentFooterCenter' }, {
text: <?php echo json_encode($config_invoice_footer); ?>,
style: 'documentFooterCenter'
},
] ]
}, },
@@ -541,11 +544,11 @@ var docDefinition = {
{ {
columns: [ columns: [
{ {
text: '<?php echo $company_name; ?>', text: <?php echo json_encode($company_name); ?>,
style:'invoiceBillingTitle', style:'invoiceBillingTitle',
}, },
{ {
text: '<?php echo $client_name; ?>', text: <?php echo json_encode($client_name); ?>,
style:'invoiceBillingTitleClient', style:'invoiceBillingTitleClient',
}, },
] ]
@@ -554,11 +557,11 @@ var docDefinition = {
{ {
columns: [ columns: [
{ {
text: '<?php echo $company_address; ?> \n <?php echo "$company_city $company_state $company_zip"; ?> \n <?php echo $company_phone; ?> \n <?php echo $company_website; ?>', text: <?php echo json_encode("$company_address \n $company_city $company_state $company_zip \n $company_phone \n $company_website"); ?>,
style: 'invoiceBillingAddress' style: 'invoiceBillingAddress'
}, },
{ {
text: '<?php echo $client_address; ?> \n <?php echo "$client_city $client_state $client_zip"; ?> \n <?php echo $client_email; ?> \n <?php echo $client_phone; ?>', text: <?php echo json_encode("$client_address \n $client_city $client_state $client_zip \n $client_email \n $client_phone"); ?>,
style: 'invoiceBillingAddressClient' style: 'invoiceBillingAddressClient'
}, },
] ]
@@ -608,7 +611,7 @@ var docDefinition = {
[ [
{ {
text: 'Product', text: 'Product',
style: 'itemsHeader' style: [ 'itemsHeader', 'left']
}, },
{ {
text: 'Qty', text: 'Qty',
@@ -616,15 +619,15 @@ var docDefinition = {
}, },
{ {
text: 'Price', text: 'Price',
style: [ 'itemsHeader', 'center'] style: [ 'itemsHeader', 'right']
}, },
{ {
text: 'Tax', text: 'Tax',
style: [ 'itemsHeader', 'center'] style: [ 'itemsHeader', 'right']
}, },
{ {
text: 'Total', text: 'Total',
style: [ 'itemsHeader', 'center'] style: [ 'itemsHeader', 'right']
} }
], ],
// Items // Items
@@ -653,11 +656,11 @@ var docDefinition = {
[ [
[ [
{ {
text: '<?php echo $item_name; ?>', text: <?php echo json_encode($item_name); ?>,
style:'itemTitle' style:'itemTitle'
}, },
{ {
text: '<?php echo $item_description; ?>', text: <?php echo json_encode($item_description); ?>,
style:'itemDescription' style:'itemDescription'
} }
], ],
@@ -675,7 +678,7 @@ var docDefinition = {
}, },
{ {
text: '$<?php echo $item_total; ?>', text: '$<?php echo $item_total; ?>',
style:'itemTotal' style:'itemNumber'
} }
], ],
@@ -720,11 +723,11 @@ var docDefinition = {
[ [
{ {
text:'Total', text:'Total',
style:'itemsFooterTotalTitle' style:'itemsFooterSubTitle'
}, },
{ {
text: '$<?php echo number_format($invoice_amount,2); ?>', text: '$<?php echo number_format($invoice_amount,2); ?>',
style:'itemsFooterTotalValue' style:'itemsFooterSubValue'
} }
], ],
[ [
@@ -740,11 +743,12 @@ var docDefinition = {
[ [
{ {
text:'Balance', text:'Balance',
style:'itemsFooterSubTitle' style:'itemsFooterTotalTitle'
}, },
{ {
text: '$<?php echo number_format($balance,2); ?>', text: '$<?php echo number_format($balance,2); ?>',
style:'itemsFooterSubValue'
style:'itemsFooterTotalTitle'
} }
], ],
] ]
@@ -756,7 +760,7 @@ var docDefinition = {
style:'notesTitle' style:'notesTitle'
}, },
{ {
text: '<?php //echo $invoice_note; ?>', text: <?php echo json_encode($invoice_note); ?>,
style:'notesText' style:'notesText'
} }
], //End Content, ], //End Content,
@@ -817,7 +821,8 @@ var docDefinition = {
itemsHeader: { itemsHeader: {
fontSize: 10, fontSize: 10,
margin: [0,5,0,5], margin: [0,5,0,5],
bold: true bold: true,
alignment:'right'
}, },
// Item Title // Item Title
itemTitle: { itemTitle: {
@@ -839,13 +844,13 @@ var docDefinition = {
itemNumber: { itemNumber: {
fontSize: 10, fontSize: 10,
margin: [0,5,0,5], margin: [0,5,0,5],
alignment: 'center', alignment: 'right',
}, },
itemTotal: { itemTotal: {
fontSize: 10, fontSize: 10,
margin: [0,5,0,5], margin: [0,5,0,5],
bold: true, bold: true,
alignment: 'center', alignment: 'right',
}, },
// Items Footer (Subtotal, Total, Tax, etc) // Items Footer (Subtotal, Total, Tax, etc)
itemsFooterSubTitle: { itemsFooterSubTitle: {
@@ -856,8 +861,8 @@ var docDefinition = {
itemsFooterSubValue: { itemsFooterSubValue: {
fontSize: 10, fontSize: 10,
margin: [0,5,0,5], margin: [0,5,0,5],
bold: true, bold: false,
alignment:'center', alignment:'right',
}, },
itemsFooterTotalTitle: { itemsFooterTotalTitle: {
fontSize: 10, fontSize: 10,
@@ -869,7 +874,7 @@ var docDefinition = {
fontSize: 10, fontSize: 10,
margin: [0,5,0,5], margin: [0,5,0,5],
bold: true, bold: true,
alignment:'center', alignment:'right',
}, },
notesTitle: { notesTitle: {
fontSize: 10, fontSize: 10,
@@ -879,6 +884,9 @@ var docDefinition = {
notesText: { notesText: {
fontSize: 10 fontSize: 10
}, },
left: {
alignment:'left',
},
center: { center: {
alignment:'center', alignment:'center',
}, },