From 9bcea0cf58c5857424ddd844c03e7594cc129ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 20 Oct 2020 12:46:08 +0200 Subject: [PATCH 1/2] Fix for invoice custom fields --- app/Services/PdfMaker/Design.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 267c3555e75f..53ffbb89e8eb 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -168,10 +168,19 @@ class Design extends BaseDesign $elements = []; foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'elements' => [ - ['element' => 'th', 'content' => $variable . '_label'], - ['element' => 'th', 'content' => $variable], - ]]; + $_variable = explode('.', $variable)[1]; + + if ($_variable == 'custom1' || $_variable == 'custom2') { + $elements[] = ['element' => 'tr', 'elements' => [ + ['element' => 'th', 'content' => $variable . '_label'], + ['element' => 'th', 'content' => $variable], + ]]; + } else { + $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'elements' => [ + ['element' => 'th', 'content' => $variable . '_label'], + ['element' => 'th', 'content' => $variable], + ]]; + } } return $elements; From 1de6f94f103f9f1fba5075048c93b6a0ddeddcf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 20 Oct 2020 13:01:07 +0200 Subject: [PATCH 2/2] fix custom1234 --- app/Http/Controllers/PreviewController.php | 2 +- app/Jobs/Invoice/CreateInvoicePdf.php | 2 ++ app/Services/PdfMaker/Design.php | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 0d46c509b0c6..a59cd0a9286e 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -196,7 +196,7 @@ class PreviewController extends BaseController ->design($design) ->build(); - // info($maker->getCompiledHTML(true)); + info($maker->getCompiledHTML(true)); $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); diff --git a/app/Jobs/Invoice/CreateInvoicePdf.php b/app/Jobs/Invoice/CreateInvoicePdf.php index 6695c3a429dd..965bde1c3a9a 100644 --- a/app/Jobs/Invoice/CreateInvoicePdf.php +++ b/app/Jobs/Invoice/CreateInvoicePdf.php @@ -109,6 +109,8 @@ class CreateInvoicePdf implements ShouldQueue ->design($template) ->build(); + info($maker->getCompiledHTML()); + //todo - move this to the client creation stage so we don't keep hitting this unnecessarily Storage::makeDirectory($path, 0775); diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 53ffbb89e8eb..8d1052be02c9 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -169,8 +169,9 @@ class Design extends BaseDesign foreach ($variables as $variable) { $_variable = explode('.', $variable)[1]; - - if ($_variable == 'custom1' || $_variable == 'custom2') { + $_customs = ['custom1', 'custom2', 'custom3', 'custom4']; + + if (in_array($_variable, $_customs)) { $elements[] = ['element' => 'tr', 'elements' => [ ['element' => 'th', 'content' => $variable . '_label'], ['element' => 'th', 'content' => $variable],