From 0da944a8875bbbe45705df3e47da5e5e3ae2666b Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 4 Feb 2018 10:32:36 +0200 Subject: [PATCH] Limit bulk emailing --- app/Models/User.php | 8 ++++++++ app/Ninja/Datatables/InvoiceDatatable.php | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 6c18b1748674..687084362beb 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -135,6 +135,14 @@ class User extends Authenticatable return $this->account->isPro(); } + /** + * @return mixed + */ + public function isPaidPro() + { + return $this->account->isPro() && ! $this->account->isTrial(); + } + /** * @return mixed */ diff --git a/app/Ninja/Datatables/InvoiceDatatable.php b/app/Ninja/Datatables/InvoiceDatatable.php index 33bc529ab5bb..6a49896767c9 100644 --- a/app/Ninja/Datatables/InvoiceDatatable.php +++ b/app/Ninja/Datatables/InvoiceDatatable.php @@ -196,10 +196,12 @@ class InvoiceDatatable extends EntityDatatable 'label' => mtrans($this->entityType, 'download_' . $this->entityType), 'url' => 'javascript:submitForm_'.$this->entityType.'("download")', ]; - $actions[] = [ - 'label' => mtrans($this->entityType, 'email_' . $this->entityType), - 'url' => 'javascript:submitForm_'.$this->entityType.'("emailInvoice")', - ]; + if (Utils::isSelfHost() || auth()->user()->isPaidPro()) { + $actions[] = [ + 'label' => mtrans($this->entityType, 'email_' . $this->entityType), + 'url' => 'javascript:submitForm_'.$this->entityType.'("emailInvoice")', + ]; + } $actions[] = \DropdownButton::DIVIDER; $actions[] = [ 'label' => mtrans($this->entityType, 'mark_sent'),