From 6803af130d30c4f88baaf23c1a6ffe600654b010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= Date: Thu, 14 Jul 2022 01:27:36 +0300 Subject: [PATCH] hidden from customers without email --- app/Models/Banking/Transaction.php | 26 ++++++++++++++------------ app/Models/Document/Document.php | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index f0939d374..6e57559e7 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -72,7 +72,7 @@ class Transaction extends Model * * @var array */ - public $sortable = ['type', 'number', 'paid_at', 'amount','category.name', 'account.name', 'customer.name', 'invoice.document_number']; + public $sortable = ['type', 'number', 'paid_at', 'amount', 'category.name', 'account.name', 'customer.name', 'invoice.document_number']; /** * Clonable relationships. @@ -552,17 +552,19 @@ class Transaction extends Model } catch (\Exception $e) {} try { - $actions[] = [ - 'type' => 'button', - 'title' => trans('invoices.send_mail'), - 'icon' => 'email', - 'url' => route('modals.transactions.emails.create', $this->id), - 'permission' => 'read-banking-transactions', - 'attributes' => [ - 'id' => 'index-more-actions-send-email-' . $this->id, - '@click' => 'onEmail("' . route('modals.transactions.emails.create', $this->id) . '")', - ], - ]; + if (! empty($this->contact) && $this->contact->email) { + $actions[] = [ + 'type' => 'button', + 'title' => trans('invoices.send_mail'), + 'icon' => 'email', + 'url' => route('modals.transactions.emails.create', $this->id), + 'permission' => 'read-banking-transactions', + 'attributes' => [ + 'id' => 'index-more-actions-send-email-' . $this->id, + '@click' => 'onEmail("' . route('modals.transactions.emails.create', $this->id) . '")', + ], + ]; + } } catch (\Exception $e) {} $actions[] = [ diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index df5587684..d5ca3237a 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -575,7 +575,7 @@ class Document extends Model } catch (\Exception $e) {} try { - if ($this->type == 'invoice') { + if (! empty($this->contact) && $this->contact->email && $this->type == 'invoice') { $actions[] = [ 'type' => 'button', 'title' => trans('invoices.send_mail'),