mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Support filtering email notifications
This commit is contained in:
parent
96666a3af8
commit
a70d4bc805
@ -1092,6 +1092,7 @@ class AccountController extends BaseController
|
|||||||
$user->notify_viewed = Input::get('notify_viewed');
|
$user->notify_viewed = Input::get('notify_viewed');
|
||||||
$user->notify_paid = Input::get('notify_paid');
|
$user->notify_paid = Input::get('notify_paid');
|
||||||
$user->notify_approved = Input::get('notify_approved');
|
$user->notify_approved = Input::get('notify_approved');
|
||||||
|
$user->only_notify_owned = Input::get('only_notify_owned');
|
||||||
$user->slack_webhook_url = Input::get('slack_webhook_url');
|
$user->slack_webhook_url = Input::get('slack_webhook_url');
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
@ -1235,6 +1236,7 @@ class AccountController extends BaseController
|
|||||||
$user->notify_viewed = Input::get('notify_viewed');
|
$user->notify_viewed = Input::get('notify_viewed');
|
||||||
$user->notify_paid = Input::get('notify_paid');
|
$user->notify_paid = Input::get('notify_paid');
|
||||||
$user->notify_approved = Input::get('notify_approved');
|
$user->notify_approved = Input::get('notify_approved');
|
||||||
|
$user->only_notify_owned = Input::get('only_notify_owned');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->google_2fa_secret && ! Input::get('enable_two_factor')) {
|
if ($user->google_2fa_secret && ! Input::get('enable_two_factor')) {
|
||||||
|
@ -478,6 +478,28 @@ class User extends Authenticatable
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ownsEntity($entity)
|
||||||
|
{
|
||||||
|
return $entity->user_id == $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldNotify($invoice)
|
||||||
|
{
|
||||||
|
if (! $this->email || ! $this->confirmed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->cannot('view', $invoice)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->only_notify_owned && ! $this->ownsEntity($invoice)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
User::created(function ($user)
|
User::created(function ($user)
|
||||||
|
@ -76,7 +76,7 @@ class UserMailer extends Mailer
|
|||||||
Payment $payment = null,
|
Payment $payment = null,
|
||||||
$notes = false
|
$notes = false
|
||||||
) {
|
) {
|
||||||
if (! $user->email || $user->cannot('view', $invoice)) {
|
if (! $user->shouldNotify($invoice)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2844,6 +2844,9 @@ $LANG = array(
|
|||||||
'show_aging' => 'Show Aging',
|
'show_aging' => 'Show Aging',
|
||||||
'reference' => 'Reference',
|
'reference' => 'Reference',
|
||||||
'amount_paid' => 'Amount Paid',
|
'amount_paid' => 'Amount Paid',
|
||||||
|
'send_notifications_for' => 'Send Notifications For',
|
||||||
|
'all_invoices' => 'All Invoices',
|
||||||
|
'my_invoices' => 'My Invoices',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2,15 +2,25 @@
|
|||||||
{{ Former::populateField('notify_viewed', intval(Auth::user()->notify_viewed)) }}
|
{{ Former::populateField('notify_viewed', intval(Auth::user()->notify_viewed)) }}
|
||||||
{{ Former::populateField('notify_paid', intval(Auth::user()->notify_paid)) }}
|
{{ Former::populateField('notify_paid', intval(Auth::user()->notify_paid)) }}
|
||||||
{{ Former::populateField('notify_approved', intval(Auth::user()->notify_approved)) }}
|
{{ Former::populateField('notify_approved', intval(Auth::user()->notify_approved)) }}
|
||||||
|
{{ Former::populateField('only_notify_owned', intval(Auth::user()->only_notify_owned)) }}
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">{!! trans('texts.email_notifications') !!}</h3>
|
<h3 class="panel-title">{!! trans('texts.email_notifications') !!}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{!! Former::checkbox('notify_sent')->label(' ')->text(trans('texts.email_sent'))->value(1) !!}
|
{!! Former::checkbox('notify_sent')->label(' ')->text(trans('texts.email_sent'))->value(1) !!}
|
||||||
{!! Former::checkbox('notify_viewed')->label(' ')->text(trans('texts.email_viewed'))->value(1) !!}
|
{!! Former::checkbox('notify_viewed')->label(' ')->text(trans('texts.email_viewed'))->value(1) !!}
|
||||||
{!! Former::checkbox('notify_paid')->label(' ')->text(trans('texts.email_paid'))->value(1) !!}
|
{!! Former::checkbox('notify_paid')->label(' ')->text(trans('texts.email_paid'))->value(1) !!}
|
||||||
{!! Former::checkbox('notify_approved')->label(' ')->text(trans('texts.email_approved'))->value(1) !!}
|
{!! Former::checkbox('notify_approved')->label(' ')->text(trans('texts.email_approved'))->value(1) !!}
|
||||||
|
|
||||||
|
@if (true || Auth()->user()->account->users->count() > 1)
|
||||||
|
<br/>
|
||||||
|
{!! Former::radios('only_notify_owned')->radios([
|
||||||
|
trans('texts.all_invoices') => array('name' => 'only_notify_owned', 'value' => 0),
|
||||||
|
trans('texts.my_invoices') => array('name' => 'only_notify_owned', 'value' => 1),
|
||||||
|
])->inline()
|
||||||
|
->label('send_notifications_for') !!}
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user