Skip to content

Commit

Permalink
close #2131 (#97v2nm) Fixed: Invoice/Bill title of documents' PDF/pri…
Browse files Browse the repository at this point in the history
…nt templates
  • Loading branch information
cuneytsenturk committed Jun 22, 2021
1 parent 4936995 commit 9217f88
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 15 deletions.
47 changes: 47 additions & 0 deletions app/Abstracts/View/Components/DocumentShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -377,6 +383,7 @@ public function __construct(
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,
Expand Down Expand Up @@ -474,6 +481,8 @@ public function __construct(
$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);
Expand Down Expand Up @@ -1136,6 +1145,44 @@ protected function getTimelineStatuses($type, $hideTimelineStatuses)
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)) {
Expand Down
48 changes: 48 additions & 0 deletions app/Abstracts/View/Components/DocumentTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Image;
use Intervention\Image\Exception\NotReadableException;
use Storage;
use Illuminate\Support\Str;

abstract class DocumentTemplate extends Base
{
Expand Down Expand Up @@ -68,6 +69,12 @@ abstract class DocumentTemplate extends Base

public $hideDueAt;

/** @var string */
public $textDocumentTitle;

/** @var string */
public $textDocumentSubheading;

public $textContactInfo;

/** @var string */
Expand Down Expand Up @@ -121,6 +128,7 @@ public function __construct(
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 = ''
Expand Down Expand Up @@ -151,6 +159,8 @@ public function __construct(
$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);
Expand Down Expand Up @@ -259,6 +269,44 @@ protected function getBackgroundColor($type, $backgroundColor)
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)) {
Expand Down
2 changes: 2 additions & 0 deletions resources/views/components/documents/show/content.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class-header-due-at="{{ $classHeaderDueAt }}"
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 }}"
Expand Down
6 changes: 6 additions & 0 deletions resources/views/components/documents/show/document.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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 }}"
Expand Down
11 changes: 6 additions & 5 deletions resources/views/components/documents/template/classic.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<div class="col-100">
<div class="text">
<h3>
{{ setting('invoice.title') }}
{{ $textDocumentTitle }}
</h3>
@if (setting('invoice.subheading'))
<h5>
{{ setting('invoice.subheading') }}
</h5>

@if ($textDocumentSubheading)
<h5>
{{ $textDocumentSubheading }}
</h5>
@endif
</div>
</div>
Expand Down
11 changes: 6 additions & 5 deletions resources/views/components/documents/template/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<div class="col-100">
<div class="text">
<h3>
{{ setting('invoice.title') }}
{{ $textDocumentTitle }}
</h3>
@if (setting('invoice.subheading'))
<h5>
{{ setting('invoice.subheading') }}
</h5>

@if ($textDocumentSubheading)
<h5>
{{ $textDocumentSubheading }}
</h5>
@endif
</div>
</div>
Expand Down
11 changes: 6 additions & 5 deletions resources/views/components/documents/template/modern.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<div class="col-100">
<div class="text">
<h3>
{{ setting('invoice.title') }}
{{ $textDocumentTitle }}
</h3>
@if (setting('invoice.subheading'))
<h5>
{{ setting('invoice.subheading') }}
</h5>

@if ($textDocumentSubheading)
<h5>
{{ $textDocumentSubheading }}
</h5>
@endif
</div>
</div>
Expand Down

0 comments on commit 9217f88

Please sign in to comment.