Remove client from invoice due notifications #1578

This commit is contained in:
Hillel Coren 2017-11-30 19:33:27 +02:00
parent 31d7481903
commit 7bde6da3e9
7 changed files with 35 additions and 0 deletions

View File

@ -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
*

View File

@ -60,6 +60,7 @@ class Client extends EntityModel
'shipping_postal_code',
'shipping_country_id',
'show_tasks_in_portal',
'send_reminders',
];
/**

View File

@ -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)

View File

@ -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,
]);
}

View File

@ -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',
);

View File

@ -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
</div>
<div role="tabpanel" class="tab-pane" id="notes">
{!! Former::textarea('public_notes')->rows(6) !!}

View File

@ -139,6 +139,15 @@
@endif
<p>{{ $client->present()->paymentTerms }}</p>
<div class="text-muted" style="padding-top:8px">
@if ($client->show_tasks_in_portal)
{{ trans('texts.can_view_tasks') }}<br/>
@endif
@if ($client->account->hasReminders() && ! $client->send_reminders)
{{ trans('texts.is_not_sent_reminders') }}</br>
@endif
</div>
</div>
<div class="col-md-3">