From 9217f88052756a4ecdc671b958d82b2bf7a05fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Tue, 22 Jun 2021 12:12:47 +0300 Subject: [PATCH] close #2131 (#97v2nm) Fixed: Invoice/Bill title of documents' PDF/print templates --- .../View/Components/DocumentShow.php | 47 ++++++++++++++++++ .../View/Components/DocumentTemplate.php | 48 +++++++++++++++++++ .../documents/show/content.blade.php | 2 + .../documents/show/document.blade.php | 6 +++ .../documents/template/classic.blade.php | 11 +++-- .../documents/template/default.blade.php | 11 +++-- .../documents/template/modern.blade.php | 11 +++-- 7 files changed, 121 insertions(+), 15 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentShow.php b/app/Abstracts/View/Components/DocumentShow.php index 4a2e248dd..fddbede90 100644 --- a/app/Abstracts/View/Components/DocumentShow.php +++ b/app/Abstracts/View/Components/DocumentShow.php @@ -236,6 +236,12 @@ abstract class DocumentShow extends Base /** @var bool */ public $hideTimelineCreate; + /** @var string */ + public $textDocumentTitle; + + /** @var string */ + public $textDocumentSubheading; + /** @var string */ public $textTimelineCreateTitle; @@ -377,6 +383,7 @@ abstract class DocumentShow extends Base string $textHeaderContact = '', string $textHeaderAmount = '', string $textHeaderDueAt = '', string $classHeaderStatus = '', string $classHeaderContact = '', string $classHeaderAmount = '', string $classHeaderDueAt = '', string $classFooterHistories = '', string $classFooterTransactions = '', bool $hideHeaderStatus = false, bool $hideHeaderContact = false, bool $hideHeaderAmount = false, bool $hideHeaderDueAt = false, + string $textDocumentTitle = '', string $textDocumentSubheading = '', string $textTimelineCreateTitle = '', string $textTimelineCreateMessage = '', string $textTimelineSentTitle = '', string $textTimelineSentStatusDraft = '', string $textTimelineSentStatusMarkSent = '', string $textTimelineSentStatusReceived = '', string $textTimelineSendStatusMail = '', string $textTimelineGetPaidTitle = '', string $textTimelineGetPaidStatusAwait = '', string $textTimelineGetPaidStatusPartiallyPaid = '', string $textTimelineGetPaidMarkPaid = '', string $textTimelineGetPaidAddPayment = '', bool $hideTimelineCreate = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, @@ -474,6 +481,8 @@ abstract class DocumentShow extends Base $this->hideButtonShare = $hideButtonShare; $this->hideButtonPaid = $hideButtonPaid; + $this->textDocumentTitle = $this->getTextDocumentTitle($type, $textDocumentTitle); + $this->textDocumentSubheading = $this->gettextDocumentSubheading($type, $textDocumentSubheading); $this->textTimelineCreateTitle = $this->getTextTimelineCreateTitle($type, $textTimelineCreateTitle); $this->textTimelineCreateMessage = $this->getTextTimelineCreateMessage($type, $textTimelineCreateMessage); $this->textTimelineSentTitle = $this->getTextTimelineSentTitle($type, $textTimelineSentTitle); @@ -1136,6 +1145,44 @@ abstract class DocumentShow extends Base return $hideTimelineStatuses; } + protected function getTextDocumentTitle($type, $textDocumentTitle) + { + if (!empty($textDocumentTitle)) { + return $textDocumentTitle; + } + + $translation = $this->getTextFromConfig($type, 'document_title', 'title'); + + if (!empty($translation)) { + return $translation; + } + + if (!empty(setting($type . '.title'))) { + return setting($type . '.title'); + } + + return setting('invoice.title'); + } + + protected function getTextDocumentSubheading($type, $textDocumentSubheading) + { + if (!empty($textDocumentSubheading)) { + return $textDocumentSubheading; + } + + $translation = $this->getTextFromConfig($type, 'document_subheading', 'subheading'); + + if (!empty($translation)) { + return $translation; + } + + if (!empty(setting($type . '.subheading'))) { + return setting($type . '.subheading'); + } + + return setting('invoice.subheading'); + } + protected function getTextTimelineCreateTitle($type, $textTimelineCreateTitle) { if (!empty($textTimelineCreateTitle)) { diff --git a/app/Abstracts/View/Components/DocumentTemplate.php b/app/Abstracts/View/Components/DocumentTemplate.php index 713084314..a89609664 100644 --- a/app/Abstracts/View/Components/DocumentTemplate.php +++ b/app/Abstracts/View/Components/DocumentTemplate.php @@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Log; use Image; use Intervention\Image\Exception\NotReadableException; use Storage; +use Illuminate\Support\Str; abstract class DocumentTemplate extends Base { @@ -68,6 +69,12 @@ abstract class DocumentTemplate extends Base public $hideDueAt; + /** @var string */ + public $textDocumentTitle; + + /** @var string */ + public $textDocumentSubheading; + public $textContactInfo; /** @var string */ @@ -121,6 +128,7 @@ abstract class DocumentTemplate extends Base bool $hideCompanyName = false, bool $hideCompanyAddress = false, bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, bool $hideContactPhone = false, bool $hideContactEmail = false, bool $hideOrderNumber = false, bool $hideDocumentNumber = false, bool $hideIssuedAt = false, bool $hideDueAt = false, + string $textDocumentTitle = '', string $textDocumentSubheading = '', string $textContactInfo = '', string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '', bool $hideItems = false, bool $hideName = false, bool $hideDescription = false, bool $hideQuantity = false, bool $hidePrice = false, bool $hideDiscount = false, bool $hideAmount = false, bool $hideNote = false, string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = '' @@ -151,6 +159,8 @@ abstract class DocumentTemplate extends Base $this->hideIssuedAt = $hideIssuedAt; $this->hideDueAt = $hideDueAt; + $this->textDocumentTitle = $this->getTextDocumentTitle($type, $textDocumentTitle); + $this->textDocumentSubheading = $this->gettextDocumentSubheading($type, $textDocumentSubheading); $this->textContactInfo = $this->getTextContactInfo($type, $textContactInfo); $this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt); $this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber); @@ -259,6 +269,44 @@ abstract class DocumentTemplate extends Base return $backgroundColor; } + protected function getTextDocumentTitle($type, $textDocumentTitle) + { + if (!empty($textDocumentTitle)) { + return $textDocumentTitle; + } + + if (!empty(setting($type . '.title'))) { + return setting($type . '.title'); + } + + $translation = $this->getTextFromConfig($type, 'document_title', Str::plural($type)); + + if (!empty($translation)) { + return trans_choice($translation, 1); + } + + return setting('invoice.title'); + } + + protected function getTextDocumentSubheading($type, $textDocumentSubheading) + { + if (!empty($textDocumentSubheading)) { + return $textDocumentSubheading; + } + + if (!empty(setting($type . '.subheading'))) { + return setting($type . '.subheading'); + } + + $translation = $this->getTextFromConfig($type, 'document_subheading', 'subheading'); + + if (!empty($translation)) { + return trans($translation); + } + + return false; + } + protected function getTextDocumentNumber($type, $textDocumentNumber) { if (!empty($textDocumentNumber)) { diff --git a/resources/views/components/documents/show/content.blade.php b/resources/views/components/documents/show/content.blade.php index 653838972..41abf848d 100644 --- a/resources/views/components/documents/show/content.blade.php +++ b/resources/views/components/documents/show/content.blade.php @@ -108,6 +108,8 @@ text-document-number="{{ $textDocumentNumber }}" text-due-at="{{ $textDueAt }}" text-order-number="{{ $textOrderNumber }}" + text-document-title="{{ $textDocumentTitle }}" + text-document-subheading="{{ $textDocumentSubheading }}" hide-items="{{ $hideItems }}" hide-name="{{ $hideName }}" hide-description="{{ $hideDescription }}" diff --git a/resources/views/components/documents/show/document.blade.php b/resources/views/components/documents/show/document.blade.php index d814666e2..2e7a0cec4 100644 --- a/resources/views/components/documents/show/document.blade.php +++ b/resources/views/components/documents/show/document.blade.php @@ -34,6 +34,8 @@ text-document-number="{{ $textDocumentNumber }}" text-due-at="{{ $textDueAt }}" text-order-number="{{ $textOrderNumber }}" + text-document-title="{{ $textDocumentTitle }}" + text-document-subheading="{{ $textDocumentSubheading }}" hide-items="{{ $hideItems }}" hide-name="{{ $hideName }}" hide-description="{{ $hideDescription }}" @@ -77,6 +79,8 @@ text-document-number="{{ $textDocumentNumber }}" text-due-at="{{ $textDueAt }}" text-order-number="{{ $textOrderNumber }}" + text-document-title="{{ $textDocumentTitle }}" + text-document-subheading="{{ $textDocumentSubheading }}" hide-items="{{ $hideItems }}" hide-name="{{ $hideName }}" hide-description="{{ $hideDescription }}" @@ -120,6 +124,8 @@ text-document-number="{{ $textDocumentNumber }}" text-due-at="{{ $textDueAt }}" text-order-number="{{ $textOrderNumber }}" + text-document-title="{{ $textDocumentTitle }}" + text-document-subheading="{{ $textDocumentSubheading }}" hide-items="{{ $hideItems }}" hide-name="{{ $hideName }}" hide-description="{{ $hideDescription }}" diff --git a/resources/views/components/documents/template/classic.blade.php b/resources/views/components/documents/template/classic.blade.php index 58dfa4024..dee9dfeae 100644 --- a/resources/views/components/documents/template/classic.blade.php +++ b/resources/views/components/documents/template/classic.blade.php @@ -2,12 +2,13 @@

- {{ setting('invoice.title') }} + {{ $textDocumentTitle }}

- @if (setting('invoice.subheading')) -
- {{ setting('invoice.subheading') }} -
+ + @if ($textDocumentSubheading) +
+ {{ $textDocumentSubheading }} +
@endif
diff --git a/resources/views/components/documents/template/default.blade.php b/resources/views/components/documents/template/default.blade.php index 8b8b49446..6ad256425 100644 --- a/resources/views/components/documents/template/default.blade.php +++ b/resources/views/components/documents/template/default.blade.php @@ -2,12 +2,13 @@

- {{ setting('invoice.title') }} + {{ $textDocumentTitle }}

- @if (setting('invoice.subheading')) -
- {{ setting('invoice.subheading') }} -
+ + @if ($textDocumentSubheading) +
+ {{ $textDocumentSubheading }} +
@endif
diff --git a/resources/views/components/documents/template/modern.blade.php b/resources/views/components/documents/template/modern.blade.php index 4c8b1acfb..9852464d6 100644 --- a/resources/views/components/documents/template/modern.blade.php +++ b/resources/views/components/documents/template/modern.blade.php @@ -2,12 +2,13 @@

- {{ setting('invoice.title') }} + {{ $textDocumentTitle }}

- @if (setting('invoice.subheading')) -
- {{ setting('invoice.subheading') }} -
+ + @if ($textDocumentSubheading) +
+ {{ $textDocumentSubheading }} +
@endif