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 +{{ trans($textContactInfo) }}
++ {{ trans($textContactInfo) }} +
@endif @stack('name_input_start') @if (! $hideContactName) -{{ $document->contact_name }}
+ @if ($print) ++ {{ $document->contact_name }} +
+ @else +- {{ $document->contact_name }} -
+ @if ($print) ++ {{ $document->contact_name }} +
+ @else +