Merge pull request #6732 from beganovich/v5-704

Statement improvements & fixes
This commit is contained in:
David Bomba 2021-09-28 07:47:33 +10:00 committed by GitHub
commit 01b65cfc8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -605,6 +605,16 @@ class Design extends BaseDesign
public function tableTotals(): array public function tableTotals(): array
{ {
if ($this->type === self::STATEMENT) {
return [
['element' => 'div', 'properties' => ['style' => 'display: flex; flex-direction: column;'], 'elements' => [
['element' => 'div', 'properties' => ['style' => 'margin-top: 1.5rem; display: flex; align-items: flex-start;'], 'elements' => [
['element' => 'img', 'properties' => ['src' => '$invoiceninja.whitelabel', 'style' => 'height: 2.5rem;', 'hidden' => $this->entity->user->account->isPaid() ? 'true' : 'false', 'id' => 'invoiceninja-whitelabel-logo']],
]],
]],
];
}
$_variables = array_key_exists('variables', $this->context) $_variables = array_key_exists('variables', $this->context)
? $this->context['variables'] ? $this->context['variables']
: ['values' => ['$entity.public_notes' => $this->entity->public_notes, '$entity.terms' => $this->entity->terms, '$entity_footer' => $this->entity->footer], 'labels' => []]; : ['values' => ['$entity.public_notes' => $this->entity->public_notes, '$entity.terms' => $this->entity->terms, '$entity_footer' => $this->entity->footer], 'labels' => []];
@ -626,7 +636,7 @@ class Design extends BaseDesign
['element' => 'div', 'properties' => ['class' => 'totals-table-right-side', 'dir' => '$dir'], 'elements' => []], ['element' => 'div', 'properties' => ['class' => 'totals-table-right-side', 'dir' => '$dir'], 'elements' => []],
]; ];
if ($this->type == self::DELIVERY_NOTE || $this->type == self::STATEMENT) { if ($this->type == self::DELIVERY_NOTE) {
return $elements; return $elements;
} }

View File

@ -217,6 +217,13 @@ trait DesignHelpers
public function sharedFooterElements() public function sharedFooterElements()
{ {
// We want to show headers for statements, no exceptions.
$statements = "
document.querySelectorAll('#statement-invoice-table > thead > tr > th, #statement-payment-table > thead > tr > th, #statement-aging-table > thead > tr > th').forEach(t => {
t.hidden = false;
});
";
// Unminified version, just for the reference. // Unminified version, just for the reference.
// By default all table headers are hidden with HTML `hidden` property. // By default all table headers are hidden with HTML `hidden` property.
// This will check for table data values & if they're not empty it will remove hidden from the column itself. // This will check for table data values & if they're not empty it will remove hidden from the column itself.
@ -259,6 +266,7 @@ document.addEventListener('DOMContentLoaded', function() {
$html_decode = 'document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll(`[data-state="encoded-html"]`).forEach(e=>e.innerHTML=e.innerText)},!1);'; $html_decode = 'document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll(`[data-state="encoded-html"]`).forEach(e=>e.innerHTML=e.innerText)},!1);';
return ['element' => 'div', 'elements' => [ return ['element' => 'div', 'elements' => [
['element' => 'script', 'content' => $statements],
['element' => 'script', 'content' => $javascript], ['element' => 'script', 'content' => $javascript],
['element' => 'script', 'content' => $html_decode], ['element' => 'script', 'content' => $html_decode],
]]; ]];