diff --git a/app/Models/Account.php b/app/Models/Account.php index e9662b892033..02a94eee3dd7 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -1007,6 +1007,15 @@ class Account extends Eloquent $this->company->save(); } + public function hasReminders() + { + if (! $this->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) { + return false; + } + + return $this->enable_reminder1 || $this->enable_reminder2 || $this->enable_reminder3; + } + /** * @param $feature * diff --git a/app/Models/Client.php b/app/Models/Client.php index 44c43e378c01..6e43816505e8 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -60,6 +60,7 @@ class Client extends EntityModel 'shipping_postal_code', 'shipping_country_id', 'show_tasks_in_portal', + 'send_reminders', ]; /** diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index cfc50157aa45..873c85a377e5 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -1170,6 +1170,9 @@ class InvoiceRepository extends BaseRepository $sql = implode(' OR ', $dates); $invoices = Invoice::invoiceType(INVOICE_TYPE_STANDARD) ->with('invoice_items') + ->whereHas('client', function ($query) { + $query->whereSendReminders(true); + }) ->whereAccountId($account->id) ->where('balance', '>', 0) ->where('is_recurring', '=', false) diff --git a/app/Ninja/Transformers/ClientTransformer.php b/app/Ninja/Transformers/ClientTransformer.php index fe1f1a0b07d5..24d6161e2c78 100644 --- a/app/Ninja/Transformers/ClientTransformer.php +++ b/app/Ninja/Transformers/ClientTransformer.php @@ -45,6 +45,7 @@ class ClientTransformer extends EntityTransformer * @SWG\Property(property="shipping_postal_code", type="string", example=10010) * @SWG\Property(property="shipping_country_id", type="integer", example=840) * @SWG\Property(property="show_tasks_in_portal", type="boolean", example=false) + * @SWG\Property(property="send_reminders", type="boolean", example=false) * @SWG\Property(property="credit_number_counter", type="integer", example=1) */ protected $defaultIncludes = [ @@ -152,6 +153,7 @@ class ClientTransformer extends EntityTransformer 'shipping_postal_code' => $client->shipping_postal_code, 'shipping_country_id' => (int) $client->shipping_country_id, 'show_tasks_in_portal' => (bool) $client->show_tasks_in_portal, + 'send_reminders' => (bool) $client->send_reminders, 'credit_number_counter' => (int) $client->credit_number_counter, ]); } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 56ca39bfb928..d35722054c8d 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2593,6 +2593,10 @@ $LANG = array( 'module_quote' => 'Quotes', 'module_task' => 'Tasks & Projects', 'module_expense' => 'Expenses & Vendors', + 'reminders' => 'Reminders', + 'send_client_reminders' => 'Send email reminders', + 'can_view_tasks' => 'Tasks are visible in the portal', + 'is_not_sent_reminders' => 'Reminders are not sent', ); diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index 073f181531d5..70a924d66f58 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -25,6 +25,7 @@ {!! Former::populate($client) !!} {!! Former::populateField('task_rate', floatval($client->task_rate) ? Utils::roundSignificant($client->task_rate) : '') !!} {!! Former::populateField('show_tasks_in_portal', intval($client->show_tasks_in_portal)) !!} + {!! Former::populateField('send_reminders', intval($client->send_reminders)) !!} {!! Former::hidden('public_id') !!} @else {!! Former::populateField('invoice_number_counter', 1) !!} @@ -204,6 +205,12 @@ ->label('client_portal') ->value(1) !!} @endif + @if ($account->hasReminders()) + {!! Former::checkbox('send_reminders') + ->text('send_client_reminders') + ->label('reminders') + ->value(1) !!} + @endif
{{ $client->present()->paymentTerms }}
+ +