Include reminder number in email notification subject

This commit is contained in:
Hillel Coren 2017-04-16 10:06:42 +03:00
parent 81764778d0
commit 93dad4be94
6 changed files with 34 additions and 11 deletions

View File

@ -17,13 +17,19 @@ class InvoiceWasEmailed extends Event
*/
public $invoice;
/**
* @var string
*/
public $notes;
/**
* Create a new event instance.
*
* @param Invoice $invoice
*/
public function __construct(Invoice $invoice)
public function __construct(Invoice $invoice, $notes)
{
$this->invoice = $invoice;
$this->notes = $notes;
}
}

View File

@ -12,13 +12,19 @@ class QuoteWasEmailed extends Event
use SerializesModels;
public $quote;
/**
* @var string
*/
public $notes;
/**
* Create a new event instance.
*
* @param $quote
*/
public function __construct($quote)
public function __construct($quote, $notes)
{
$this->quote = $quote;
$this->notes = $notes;
}
}

View File

@ -35,6 +35,11 @@ class SendNotificationEmail extends Job implements ShouldQueue
*/
protected $payment;
/**
* @var string
*/
protected $notes;
/**
* Create a new job instance.
@ -46,12 +51,13 @@ class SendNotificationEmail extends Job implements ShouldQueue
* @param mixed $type
* @param mixed $payment
*/
public function __construct($user, $invoice, $type, $payment)
public function __construct($user, $invoice, $type, $payment, $notes)
{
$this->user = $user;
$this->invoice = $invoice;
$this->type = $type;
$this->payment = $payment;
$this->notes = $notes;
}
/**
@ -61,6 +67,6 @@ class SendNotificationEmail extends Job implements ShouldQueue
*/
public function handle(UserMailer $userMailer)
{
$userMailer->sendNotification($this->user, $this->invoice, $this->type, $this->payment);
$userMailer->sendNotification($this->user, $this->invoice, $this->type, $this->payment, $this->notes);
}
}

View File

@ -20,13 +20,13 @@ class NotificationListener
* @param $type
* @param null $payment
*/
private function sendEmails($invoice, $type, $payment = null)
private function sendEmails($invoice, $type, $payment = null, $notes = false)
{
foreach ($invoice->account->users as $user)
{
if ($user->{"notify_{$type}"})
{
dispatch(new SendNotificationEmail($user, $invoice, $type, $payment));
dispatch(new SendNotificationEmail($user, $invoice, $type, $payment, $notes));
}
}
}
@ -36,7 +36,7 @@ class NotificationListener
*/
public function emailedInvoice(InvoiceWasEmailed $event)
{
$this->sendEmails($event->invoice, 'sent');
$this->sendEmails($event->invoice, 'sent', null, $event->notes);
dispatch(new SendPushNotification($event->invoice, 'sent'));
}
@ -45,7 +45,7 @@ class NotificationListener
*/
public function emailedQuote(QuoteWasEmailed $event)
{
$this->sendEmails($event->quote, 'sent');
$this->sendEmails($event->quote, 'sent', null, $event->notes);
dispatch(new SendPushNotification($event->quote, 'sent'));
}

View File

@ -105,9 +105,9 @@ class ContactMailer extends Mailer
if ($sent === true) {
if ($invoice->isType(INVOICE_TYPE_QUOTE)) {
event(new QuoteWasEmailed($invoice));
event(new QuoteWasEmailed($invoice, $reminder));
} else {
event(new InvoiceWasEmailed($invoice));
event(new InvoiceWasEmailed($invoice, $reminder));
}
}

View File

@ -48,7 +48,8 @@ class UserMailer extends Mailer
User $user,
Invoice $invoice,
$notificationType,
Payment $payment = null
Payment $payment = null,
$notes = false
) {
if (! $user->email || $user->cannot('view', $invoice)) {
return;
@ -81,6 +82,10 @@ class UserMailer extends Mailer
'client' => $client->getDisplayName(),
]);
if ($notes) {
$subject .= ' [' . trans('texts.notes_' . $notes) . ']';
}
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}