From c1a92bfb52acbe81a1393165e12032f772fbd67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Apr 2021 11:04:33 +0200 Subject: [PATCH 1/2] Fixes #5312 (https://github.com/invoiceninja/invoiceninja/issues/5312) --- app/Services/PdfMaker/Design.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index ca501eb69b..7ad507f0aa 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -507,13 +507,6 @@ class Design extends BaseDesign } } - if (!is_null($this->entity->partial) && $this->entity->partial > 0) { - $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ - ['element' => 'span', 'content' => '$partial_due_label', 'properties' => ['data-ref' => 'totals_table-partial_due-label']], - ['element' => 'span', 'content' => '$partial_due'], - ]]; - } - $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ ['element' => 'span', 'content' => '',], ['element' => 'span', 'content' => ''], From 5ac1ae16ffcd7842199f2881eabdf1163ec3ff25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Apr 2021 13:22:21 +0200 Subject: [PATCH 2/2] Fixes #5314 (https://github.com/invoiceninja/invoiceninja/issues/5314) --- app/Services/PdfMaker/Design.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 7ad507f0aa..a556422ae3 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -412,11 +412,9 @@ class Design extends BaseDesign $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => 'product_table-product.tax2-td']]; } elseif ($cell == '$product.tax_rate3') { $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => 'product_table-product.tax3-td']]; - } - else if($cell == '$product.unit_cost' || $cell == '$task.rate') { + } else if ($cell == '$product.unit_cost' || $cell == '$task.rate') { $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['style' => 'white-space: nowrap;', 'data-ref' => "{$_type}_table-" . substr($cell, 1) . '-td']]; - } - else { + } else { $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => "{$_type}_table-" . substr($cell, 1) . '-td']]; } } @@ -456,7 +454,7 @@ class Design extends BaseDesign ['element' => 'div', 'properties' => ['class' => 'totals-table-right-side'], 'elements' => []], ]; - foreach (['discount', 'custom_surcharge1', 'custom_surcharge2', 'custom_surcharge3', 'custom_surcharge4'] as $property) { + foreach (['discount'] as $property) { $variable = sprintf('%s%s', '$', $property); if ( @@ -499,6 +497,14 @@ class Design extends BaseDesign ['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->context['client']), 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i]], ]]; } + } elseif (Str::startsWith($variable, '$custom')) { + $field = explode('_', $variable); + $visible = property_exists($this->client->company->custom_fields, $field[1]) && !empty($this->client->company->custom_fields->{$field[1]}); + + $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ + ['element' => 'span', 'content' => $variable . '_label', 'properties' => ['hidden' => !$visible, 'data-ref' => 'totals_table-' . substr($variable, 1) . '-label']], + ['element' => 'span', 'content' => $variable, 'properties' => ['hidden' => !$visible, 'data-ref' => 'totals_table-' . substr($variable, 1)]], + ]]; } else { $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ ['element' => 'span', 'content' => $variable . '_label', 'properties' => ['data-ref' => 'totals_table-' . substr($variable, 1) . '-label']],