From e9e4c39f17ea1ac7d338d20d28fd2c28c113507a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 21 Jan 2021 23:34:21 +1100 Subject: [PATCH] Add support for QR code variables --- app/Models/Presenters/CompanyPresenter.php | 10 ++++++++++ app/Utils/HtmlEngine.php | 2 ++ 2 files changed, 12 insertions(+) diff --git a/app/Models/Presenters/CompanyPresenter.php b/app/Models/Presenters/CompanyPresenter.php index 6cf7a76bf4..0148d1f1ad 100644 --- a/app/Models/Presenters/CompanyPresenter.php +++ b/app/Models/Presenters/CompanyPresenter.php @@ -90,4 +90,14 @@ class CompanyPresenter extends EntityPresenter return false; } } + + public function getSpcQrCode($client_custom, $invoice_number, $balance) + { + $settings = $this->entity->settings; + + return + + "SPC\n0200\n1\nCH860021421411198240K\nK\n{$this->name}\n{$settings->address1}\n{$settings->postal_code} {$settings->city}\n\n\nCH\n\n\n\n\n\n\n\n{$balance}\n{$client_custom}\n\n\n\n\n\n\n\nNON\n\n{$invoice_number}\nEPD\n"; + } + } diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index e3f19e94a3..0357db6918 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -274,6 +274,8 @@ class HtmlEngine $data['$company.website'] = ['value' => $this->settings->website ?: ' ', 'label' => ctrans('texts.website')]; $data['$company.address'] = ['value' => $this->company->present()->address($this->settings) ?: ' ', 'label' => ctrans('texts.address')]; + $data['$spc_qr_code'] = ['value' => $this->company->present()->getSpcQrCode($this->client->custom1, $this->entity->number, $this->entity->balance), 'label' => '']; + $logo = $this->company->present()->logo($this->settings); $data['$company.logo'] = ['value' => $logo ?: ' ', 'label' => ctrans('texts.logo')];