document show contact link

This commit is contained in:
Cihan Şentürk 2023-01-02 11:36:03 +03:00 committed by GitHub
parent e47d575087
commit 9dade70dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 14 deletions

View File

@ -2,19 +2,20 @@
namespace App\Abstracts\View\Components\Documents; namespace App\Abstracts\View\Components\Documents;
use App\Abstracts\View\Component; use Image;
use App\Models\Common\Media; use ReflectionProperty;
use App\Traits\DateTime; use App\Traits\DateTime;
use App\Traits\Documents;
use App\Traits\Tailwind; use App\Traits\Tailwind;
use App\Traits\Documents;
use Illuminate\Support\Str;
use App\Models\Common\Media;
use App\Traits\ViewComponents; use App\Traits\ViewComponents;
use App\Abstracts\View\Component;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\Exception\NotReadableException; use Intervention\Image\Exception\NotReadableException;
use Image;
abstract class Template extends Component abstract class Template extends Component
{ {
@ -123,6 +124,9 @@ abstract class Template extends Component
public $hideNote; public $hideNote;
/** @var bool */
public $print;
/** /**
* Create a new component instance. * Create a new component instance.
* *
@ -137,7 +141,7 @@ abstract class Template extends Component
string $textDocumentTitle = '', string $textDocumentSubheading = '', string $textDocumentTitle = '', string $textDocumentSubheading = '',
string $textContactInfo = '', string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '', 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, 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->type = $type;
$this->item = $item; $this->item = $item;
@ -186,6 +190,8 @@ abstract class Template extends Component
$this->textQuantity = $this->getTextQuantity($type, $textQuantity); $this->textQuantity = $this->getTextQuantity($type, $textQuantity);
$this->textPrice = $this->getTextPrice($type, $textPrice); $this->textPrice = $this->getTextPrice($type, $textPrice);
$this->textAmount = $this->getTextAmount($type, $textAmount); $this->textAmount = $this->getTextAmount($type, $textAmount);
$this->print = $this->getPrint($print);
// Set Parent data // Set Parent data
//$this->setParentData(); //$this->setParentData();
@ -677,4 +683,22 @@ abstract class Template extends Component
// @todo what return value invoice or always false?? // @todo what return value invoice or always false??
return setting('invoice.hide_amount', $hideAmount); 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;
}
} }

View File

@ -122,9 +122,20 @@
@stack('name_input_start') @stack('name_input_start')
@if (! $hideContactName) @if (! $hideContactName)
<p> @if ($print)
{{ $document->contact_name }} <p>
</p> {{ $document->contact_name }}
</p>
@else
<x-link href="{{ route('customers.show', $document->contact_id) }}"
override="class"
class="py-1.5 mb-3 sm:mb-0 text-xs bg-transparent hover:bg-transparent font-medium leading-6"
>
<x-link.hover>
{{ $document->contact_name }}
</x-link.hover>
</x-link>
@endif
@endif @endif
@stack('name_input_end') @stack('name_input_end')

View File

@ -78,12 +78,27 @@
<div class="col-60"> <div class="col-60">
<div class="text p-index-left"> <div class="text p-index-left">
@if (! $hideContactInfo) @if (! $hideContactInfo)
<p class="font-semibold mb-0">{{ trans($textContactInfo) }}</p> <p class="font-semibold mb-0">
{{ trans($textContactInfo) }}
</p>
@endif @endif
@stack('name_input_start') @stack('name_input_start')
@if (! $hideContactName) @if (! $hideContactName)
<p>{{ $document->contact_name }}</p> @if ($print)
<p>
{{ $document->contact_name }}
</p>
@else
<x-link href="{{ route('customers.show', $document->contact_id) }}"
override="class"
class="py-1.5 mb-3 sm:mb-0 text-xs bg-transparent hover:bg-transparent font-medium leading-6"
>
<x-link.hover>
{{ $document->contact_name }}
</x-link.hover>
</x-link>
@endif
@endif @endif
@stack('name_input_end') @stack('name_input_end')

View File

@ -91,9 +91,20 @@
@stack('name_input_start') @stack('name_input_start')
@if (! $hideContactName) @if (! $hideContactName)
<p> @if ($print)
{{ $document->contact_name }} <p>
</p> {{ $document->contact_name }}
</p>
@else
<x-link href="{{ route('customers.show', $document->contact_id) }}"
override="class"
class="py-1.5 mb-3 sm:mb-0 text-xs bg-transparent hover:bg-transparent font-medium leading-6"
>
<x-link.hover>
{{ $document->contact_name }}
</x-link.hover>
</x-link>
@endif
@endif @endif
@stack('name_input_end') @stack('name_input_end')