From 9dade70dc483a4caaba94440425a06e843c0d4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Mon, 2 Jan 2023 11:36:03 +0300 Subject: [PATCH 1/4] document show contact link --- .../View/Components/Documents/Template.php | 36 +++++++++++++++---- .../documents/template/classic.blade.php | 17 +++++++-- .../documents/template/default.blade.php | 19 ++++++++-- .../documents/template/modern.blade.php | 17 +++++++-- 4 files changed, 75 insertions(+), 14 deletions(-) diff --git a/app/Abstracts/View/Components/Documents/Template.php b/app/Abstracts/View/Components/Documents/Template.php index 56ac04ebe..fa85dd10b 100644 --- a/app/Abstracts/View/Components/Documents/Template.php +++ b/app/Abstracts/View/Components/Documents/Template.php @@ -2,19 +2,20 @@ namespace App\Abstracts\View\Components\Documents; -use App\Abstracts\View\Component; -use App\Models\Common\Media; +use Image; +use ReflectionProperty; use App\Traits\DateTime; -use App\Traits\Documents; use App\Traits\Tailwind; +use App\Traits\Documents; +use Illuminate\Support\Str; +use App\Models\Common\Media; use App\Traits\ViewComponents; +use App\Abstracts\View\Component; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; -use Illuminate\Support\Str; use Intervention\Image\Exception\NotReadableException; -use Image; abstract class Template extends Component { @@ -123,6 +124,9 @@ abstract class Template extends Component public $hideNote; + /** @var bool */ + public $print; + /** * Create a new component instance. * @@ -137,7 +141,7 @@ abstract class Template extends Component 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 = '' + string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = '', bool $print = false ) { $this->type = $type; $this->item = $item; @@ -186,6 +190,8 @@ abstract class Template extends Component $this->textQuantity = $this->getTextQuantity($type, $textQuantity); $this->textPrice = $this->getTextPrice($type, $textPrice); $this->textAmount = $this->getTextAmount($type, $textAmount); + + $this->print = $this->getPrint($print); // Set Parent data //$this->setParentData(); @@ -677,4 +683,22 @@ abstract class Template extends Component // @todo what return value invoice or always false?? return setting('invoice.hide_amount', $hideAmount); } + + protected function getPrint($print) + { + if (! empty($print)) { + return $print; + } + + $self = new ReflectionProperty($this::class, 'methodCache'); + $self->setAccessible(true); + + $values = $self->getValue(); + + if (array_key_exists('App\View\Components\Layouts\Admin', $values)) { + return false; + } + + return true; + } } diff --git a/resources/views/components/documents/template/classic.blade.php b/resources/views/components/documents/template/classic.blade.php index a9ea76999..1035f623e 100644 --- a/resources/views/components/documents/template/classic.blade.php +++ b/resources/views/components/documents/template/classic.blade.php @@ -122,9 +122,20 @@ @stack('name_input_start') @if (! $hideContactName) -

- {{ $document->contact_name }} -

+ @if ($print) +

+ {{ $document->contact_name }} +

+ @else + + + {{ $document->contact_name }} + + + @endif @endif @stack('name_input_end') diff --git a/resources/views/components/documents/template/default.blade.php b/resources/views/components/documents/template/default.blade.php index d37bb2a1d..fa7f5ac0c 100644 --- a/resources/views/components/documents/template/default.blade.php +++ b/resources/views/components/documents/template/default.blade.php @@ -78,12 +78,27 @@
@if (! $hideContactInfo) -

{{ trans($textContactInfo) }}

+

+ {{ trans($textContactInfo) }} +

@endif @stack('name_input_start') @if (! $hideContactName) -

{{ $document->contact_name }}

+ @if ($print) +

+ {{ $document->contact_name }} +

+ @else + + + {{ $document->contact_name }} + + + @endif @endif @stack('name_input_end') diff --git a/resources/views/components/documents/template/modern.blade.php b/resources/views/components/documents/template/modern.blade.php index 8a58b7c57..e77ee8204 100644 --- a/resources/views/components/documents/template/modern.blade.php +++ b/resources/views/components/documents/template/modern.blade.php @@ -91,9 +91,20 @@ @stack('name_input_start') @if (! $hideContactName) -

- {{ $document->contact_name }} -

+ @if ($print) +

+ {{ $document->contact_name }} +

+ @else + + + {{ $document->contact_name }} + + + @endif @endif @stack('name_input_end') From fa7d6a92a6f83d85642d6fa55b12e4af4172a8f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Mon, 2 Jan 2023 18:54:23 +0300 Subject: [PATCH 2/4] fix typo --- .../View/Components/Documents/Template.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/Abstracts/View/Components/Documents/Template.php b/app/Abstracts/View/Components/Documents/Template.php index fa85dd10b..4e03e1108 100644 --- a/app/Abstracts/View/Components/Documents/Template.php +++ b/app/Abstracts/View/Components/Documents/Template.php @@ -2,20 +2,19 @@ namespace App\Abstracts\View\Components\Documents; -use Image; -use ReflectionProperty; -use App\Traits\DateTime; -use App\Traits\Tailwind; -use App\Traits\Documents; -use Illuminate\Support\Str; -use App\Models\Common\Media; -use App\Traits\ViewComponents; use App\Abstracts\View\Component; +use App\Models\Common\Media; +use App\Traits\DateTime; +use App\Traits\Documents; +use App\Traits\Tailwind; +use App\Traits\ViewComponents; use Illuminate\Support\Facades\Log; -use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Str; use Intervention\Image\Exception\NotReadableException; +use Image; +use ReflectionProperty; abstract class Template extends Component { From dc0752d0a86f096a9e6951d98069e46ea13bad43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Tue, 3 Jan 2023 10:47:34 +0300 Subject: [PATCH 3/4] fixed show contact route --- .../View/Components/Documents/Template.php | 28 ++++++++++++++++++- .../documents/template/classic.blade.php | 2 +- .../documents/template/default.blade.php | 2 +- .../documents/template/modern.blade.php | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/Abstracts/View/Components/Documents/Template.php b/app/Abstracts/View/Components/Documents/Template.php index 4e03e1108..c1ab0650f 100644 --- a/app/Abstracts/View/Components/Documents/Template.php +++ b/app/Abstracts/View/Components/Documents/Template.php @@ -95,6 +95,9 @@ abstract class Template extends Component /** @var string */ public $textOrderNumber; + /** @var string */ + public $showContactRoute; + public $hideItems; public $hideName; @@ -138,7 +141,7 @@ abstract class Template extends Component 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 = '', + string $textContactInfo = '', string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '', string $showContactRoute = '', 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 = '', bool $print = false ) { @@ -171,6 +174,7 @@ abstract class Template extends Component $this->textDocumentTitle = $this->getTextDocumentTitle($type, $textDocumentTitle); $this->textDocumentSubheading = $this->gettextDocumentSubheading($type, $textDocumentSubheading); $this->textContactInfo = $this->getTextContactInfo($type, $textContactInfo); + $this->showContactRoute = $this->getShowContactRoute($type, $showContactRoute); $this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt); $this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber); $this->textDueAt = $this->getTextDueAt($type, $textDueAt); @@ -540,6 +544,28 @@ abstract class Template extends Component return 'general.amount'; } + protected function getShowContactRoute($type, $showContactRoute) + { + if (! empty($showContactRoute)) { + return $showContactRoute; + } + + + if (! empty($showRoute)) { + return $showRoute; + } + + $route = $this->getRouteFromConfig($type, 'contact.show', 1); + + if (!empty($route)) { + return $route; + } + + $default_key = Str::plural(config('type.' . static::OBJECT_TYPE . '.' . $type . '.contact_type'), 2); + + return $default_key . '.show'; + } + protected function getHideItems($type, $hideItems, $hideName, $hideDescription) { if (! empty($hideItems)) { diff --git a/resources/views/components/documents/template/classic.blade.php b/resources/views/components/documents/template/classic.blade.php index 1035f623e..f3e595417 100644 --- a/resources/views/components/documents/template/classic.blade.php +++ b/resources/views/components/documents/template/classic.blade.php @@ -127,7 +127,7 @@ {{ $document->contact_name }}

@else - diff --git a/resources/views/components/documents/template/default.blade.php b/resources/views/components/documents/template/default.blade.php index fa7f5ac0c..a4946f908 100644 --- a/resources/views/components/documents/template/default.blade.php +++ b/resources/views/components/documents/template/default.blade.php @@ -90,7 +90,7 @@ {{ $document->contact_name }}

@else - diff --git a/resources/views/components/documents/template/modern.blade.php b/resources/views/components/documents/template/modern.blade.php index e77ee8204..f4cadd165 100644 --- a/resources/views/components/documents/template/modern.blade.php +++ b/resources/views/components/documents/template/modern.blade.php @@ -96,7 +96,7 @@ {{ $document->contact_name }}

@else - From df03725ab6b3b51980422ed0ed60d7d4582dc144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Tue, 3 Jan 2023 10:48:58 +0300 Subject: [PATCH 4/4] fix typo --- app/Abstracts/View/Components/Documents/Template.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/Abstracts/View/Components/Documents/Template.php b/app/Abstracts/View/Components/Documents/Template.php index c1ab0650f..f169dc0e6 100644 --- a/app/Abstracts/View/Components/Documents/Template.php +++ b/app/Abstracts/View/Components/Documents/Template.php @@ -550,11 +550,6 @@ abstract class Template extends Component return $showContactRoute; } - - if (! empty($showRoute)) { - return $showRoute; - } - $route = $this->getRouteFromConfig($type, 'contact.show', 1); if (!empty($route)) {