mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Merge pull request #4923 from beganovich/v5-1602-invoice-footer-variable-parsing
(v5) PDF: Support for dynamic variables in invoice footer, public notes & terms
This commit is contained in:
commit
deb0cd345a
@ -128,14 +128,17 @@ class CreateEntityPdf implements ShouldQueue
|
||||
$template = new PdfMakerDesign(strtolower($design->name));
|
||||
}
|
||||
|
||||
$variables = $html->generateLabelsAndValues();
|
||||
|
||||
$state = [
|
||||
'template' => $template->elements([
|
||||
'client' => $this->entity->client,
|
||||
'entity' => $this->entity,
|
||||
'pdf_variables' => (array) $this->entity->company->settings->pdf_variables,
|
||||
'$product' => $design->design->product,
|
||||
'variables' => $variables,
|
||||
]),
|
||||
'variables' => $html->generateLabelsAndValues(),
|
||||
'variables' => $variables,
|
||||
'options' => [
|
||||
'all_pages_header' => $this->entity->client->getSetting('all_pages_header'),
|
||||
'all_pages_footer' => $this->entity->client->getSetting('all_pages_footer'),
|
||||
|
@ -421,6 +421,10 @@ class Design extends BaseDesign
|
||||
|
||||
public function tableTotals(): array
|
||||
{
|
||||
$_variables = array_key_exists('variables', $this->context)
|
||||
? $this->context['variables']
|
||||
: [];
|
||||
|
||||
if ($this->type == 'delivery_note') {
|
||||
return [];
|
||||
}
|
||||
@ -429,10 +433,11 @@ class Design extends BaseDesign
|
||||
|
||||
$elements = [
|
||||
['element' => 'div', 'properties' => ['style' => 'display: flex; flex-direction: column;'], 'elements' => [
|
||||
['element' => 'p', 'content' => '$entity.public_notes', 'properties' => ['data-ref' => 'total_table-public_notes', 'style' => 'text-align: left;']],
|
||||
['element' => 'p', 'content' => strtr($_variables['values']['$entity.public_notes'], $_variables), 'properties' => ['data-ref' => 'total_table-public_notes', 'style' => 'text-align: left;']],
|
||||
['element' => 'p', 'content' => '', 'properties' => ['style' => 'text-align: left; display: flex; flex-direction: column;'], 'elements' => [
|
||||
['element' => 'span', 'content' => '$entity.terms_label: ', 'properties' => ['hidden' => $this->entityVariableCheck('$entity.terms'), 'data-ref' => 'total_table-terms-label', 'style' => 'font-weight: bold; text-align: left;']],
|
||||
['element' => 'span', 'content' => '$entity.terms', 'properties' => ['data-ref' => 'total_table-terms', 'style' => 'text-align: left;']],
|
||||
['element' => 'span', 'content' => strtr($_variables['values']['$entity.terms'], $_variables), 'properties' => ['data-ref' => 'total_table-terms', 'style' => 'text-align: left;']],
|
||||
['element' => 'span', 'content' => strtr($_variables['values']['$entity_footer'], $_variables), 'properties' => ['data-ref' => 'total_table-footer', 'style' => 'text-align: left;']],
|
||||
]],
|
||||
['element' => 'img', 'properties' => ['hidden' => $this->client->getSetting('signature_on_pdf'), 'style' => 'max-width: 50%; height: auto;', 'src' => '$contact.signature']],
|
||||
['element' => 'div', 'properties' => ['style' => 'margin-top: 1.5rem; display: flex; align-items: flex-start;'], 'elements' => [
|
||||
|
@ -121,7 +121,7 @@ class HtmlEngine
|
||||
if ($this->entity_string == 'invoice' || $this->entity_string == 'recurring_invoice') {
|
||||
$data['$entity'] = ['value' => '', 'label' => ctrans('texts.invoice')];
|
||||
$data['$number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.invoice_number')];
|
||||
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.invoice_terms')];
|
||||
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '', 'label' => ctrans('texts.invoice_terms')];
|
||||
$data['$terms'] = &$data['$entity.terms'];
|
||||
$data['$view_link'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
|
||||
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
|
||||
@ -129,8 +129,8 @@ class HtmlEngine
|
||||
|
||||
if ($this->entity_string == 'quote') {
|
||||
$data['$entity'] = ['value' => '', 'label' => ctrans('texts.quote')];
|
||||
$data['$number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.quote_number')];
|
||||
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.quote_terms')];
|
||||
$data['$number'] = ['value' => $this->entity->number ?: '', 'label' => ctrans('texts.quote_number')];
|
||||
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '', 'label' => ctrans('texts.quote_terms')];
|
||||
$data['$terms'] = &$data['$entity.terms'];
|
||||
$data['$view_link'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
|
||||
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
|
||||
@ -138,8 +138,8 @@ class HtmlEngine
|
||||
|
||||
if ($this->entity_string == 'credit') {
|
||||
$data['$entity'] = ['value' => '', 'label' => ctrans('texts.credit')];
|
||||
$data['$number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.credit_number')];
|
||||
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.credit_terms')];
|
||||
$data['$number'] = ['value' => $this->entity->number ?: '', 'label' => ctrans('texts.credit_number')];
|
||||
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '', 'label' => ctrans('texts.credit_terms')];
|
||||
$data['$terms'] = &$data['$entity.terms'];
|
||||
$data['$view_link'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
|
||||
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')];
|
||||
|
@ -259,4 +259,4 @@
|
||||
<table id="delivery-note-table" cellspacing="0"></table>
|
||||
</div>
|
||||
|
||||
<div id="footer">$entity_footer</div>
|
||||
<div id="footer"></div>
|
||||
|
@ -217,4 +217,4 @@
|
||||
<table id="delivery-note-table" cellspacing="0"></table>
|
||||
</div>
|
||||
|
||||
<div id="footer">$entity_footer</div>
|
||||
<div id="footer"></div>
|
||||
|
@ -215,4 +215,4 @@
|
||||
<table id="delivery-note-table" cellspacing="0"></table>
|
||||
</div>
|
||||
|
||||
<div id="footer">$entity_footer</div>
|
||||
<div id="footer"></div>
|
||||
|
@ -215,5 +215,5 @@
|
||||
<table id="delivery-note-table" cellspacing="0"></table>
|
||||
</div>
|
||||
|
||||
<div id="footer">$entity_footer</div>
|
||||
<div id="footer"></div>
|
||||
|
||||
|
@ -249,4 +249,4 @@
|
||||
<table id="delivery-note-table" cellspacing="0"></table>
|
||||
</div>
|
||||
|
||||
<div id="footer">$entity_footer</div>
|
||||
<div id="footer"></div>
|
||||
|
@ -235,7 +235,7 @@
|
||||
<div style="margin-top: 195px"></div>
|
||||
<div class="footer-wrapper" id="footer">
|
||||
<div class="footer-content">
|
||||
<div>$entity_footer</div>
|
||||
<div></div>
|
||||
<div id="company-details"></div>
|
||||
<div id="company-address"></div>
|
||||
</div>
|
||||
|
@ -180,4 +180,4 @@
|
||||
<table id="delivery-note-table" cellspacing="0"></table>
|
||||
</div>
|
||||
|
||||
<div id="footer">$entity_footer</div>
|
||||
<div id="footer"></div>
|
||||
|
@ -285,7 +285,7 @@
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
$entity_footer
|
||||
|
||||
|
||||
<div style="background-color: #00968B"><!-- 1 --></div>
|
||||
<div style="background-color: #1D756E"><!-- 2 --></div>
|
||||
|
Loading…
Reference in New Issue
Block a user