From 8fd560dcced68a85ea02ec90165e8f25ef93e488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 22 Dec 2020 13:56:09 +0100 Subject: [PATCH] process custom columns --- app/Services/PdfMaker/Design.php | 1 + .../Designs/Utilities/DesignHelpers.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 14c872a34447..5cdd222c6cef 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -298,6 +298,7 @@ class Design extends BaseDesign public function buildTableHeader(string $type): array { $this->processTaxColumns($type); + $this->processCustomColumns($type); $elements = []; diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index d80c6c4b1a4d..2ce308e25ccc 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -266,4 +266,23 @@ trait DesignHelpers return $logs; } + + public function processCustomColumns(string $type): void + { + $custom_columns = []; + + foreach ((array) $this->client->company->custom_fields as $field => $value) { + info($field); + + if (\Illuminate\Support\Str::startsWith($field, $type)) { + $custom_columns[] = '$' . $type . '.' . $field; + } + } + + $key = array_search(sprintf('%s%s.description', '$', $type), $this->context['pdf_variables']["{$type}_columns"], true); + + if ($key) { + array_splice($this->context['pdf_variables']["{$type}_columns"], $key + 1, 0, $custom_columns); + } + } }