From 0640fca05fb56a2c28b4ed5e92a7614c8a4ce287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Mon, 28 Jun 2021 12:02:39 +0300 Subject: [PATCH] close #2153 Added: Making Customer/Vendor clickable on invoice/bill page #mtdg9n --- .../View/Components/DocumentShow.php | 36 ++++++++++++++++++- .../documents/show/content.blade.php | 1 + .../documents/show/header.blade.php | 4 ++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentShow.php b/app/Abstracts/View/Components/DocumentShow.php index 904b88bee..d059cfe97 100644 --- a/app/Abstracts/View/Components/DocumentShow.php +++ b/app/Abstracts/View/Components/DocumentShow.php @@ -95,6 +95,9 @@ abstract class DocumentShow extends Base /** @var string */ public $routeButtonPaid; + /** @var string */ + public $routeContactShow; + /** @var string */ public $permissionCreate; @@ -373,7 +376,7 @@ abstract class DocumentShow extends Base $type, $document, $documentTemplate = '', $logo = '', $backgroundColor = '', string $signedUrl = '', $histories = [], $transactions = [], string $textRecurringType = '', string $textStatusMessage = '', string $textHistories = '', string $textHistoryStatus = '', string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $routeButtonPdf = '', string $routeButtonCancelled = '', string $routeButtonDelete = '', string $routeButtonCustomize = '', string $routeButtonSent = '', - string $routeButtonReceived = '', string $routeButtonEmail = '', string $routeButtonPaid = '', + string $routeButtonReceived = '', string $routeButtonEmail = '', string $routeButtonPaid = '', string $routeContactShow = '', bool $checkButtonReconciled = true, bool $checkButtonCancelled = true, string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '', string $permissionTransactionDelete = '', string $permissionButtonCustomize = '', bool $hideButtonGroupDivider1 = false, bool $hideButtonGroupDivider2 = false, bool $hideButtonGroupDivider3 = false, @@ -424,6 +427,7 @@ abstract class DocumentShow extends Base $this->routeButtonCustomize = $this->getRouteButtonCustomize($type, $routeButtonCustomize); $this->routeButtonDelete = $this->getRouteButtonDelete($type, $routeButtonDelete); $this->routeButtonPaid = $this->getRouteButtonPaid($type, $routeButtonPaid); + $this->routeContactShow = $this->getRouteContactShow($type, $routeContactShow); $this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate); $this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate); @@ -886,6 +890,36 @@ abstract class DocumentShow extends Base return 'invoices.paid'; } + protected function getRouteContactShow($type, $routeContactShow) + { + if (!empty($routeContactShow)) { + return $routeContactShow; + } + + //example route parameter. + $parameter = 1; + + $route = Str::plural(config('type.' . $type . '.contact_type'), 2) . '.show'; + + try { + route($route, $config_parameters); + } catch (\Exception $e) { + try { + $route = Str::plural($type, 2) . '.' . $config_key; + + route($route, $config_parameters); + } catch (\Exception $e) { + $route = ''; + } + } + + if (!empty($route)) { + return $route; + } + + return 'customers.show'; + } + protected function getRouteButtonSent($type, $routeButtonSent) { if (!empty($routeButtonSent)) { diff --git a/resources/views/components/documents/show/content.blade.php b/resources/views/components/documents/show/content.blade.php index 41abf848d..36c1614aa 100644 --- a/resources/views/components/documents/show/content.blade.php +++ b/resources/views/components/documents/show/content.blade.php @@ -9,6 +9,7 @@ hide-header-contact="{{ $hideHeaderContact }}" text-header-contact="{{ $textHeaderContact }}" class-header-contact="{{ $classHeaderContact }}" + route-contact-show="{{ $routeContactShow }}" hide-header-amount="{{ $hideHeaderAmount }}" text-header-amount="{{ $textHeaderAmount }}" class-header-amount="{{ $classHeaderAmount }}" diff --git a/resources/views/components/documents/show/header.blade.php b/resources/views/components/documents/show/header.blade.php index 214eda433..2f0660171 100644 --- a/resources/views/components/documents/show/header.blade.php +++ b/resources/views/components/documents/show/header.blade.php @@ -25,7 +25,9 @@ - {{ $document->contact_name }} + + {{ $document->contact_name }} +