mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add events for email notifications
This commit is contained in:
parent
f93965d4e3
commit
f21444be90
@ -73,7 +73,7 @@ class EntitySentObject
|
|||||||
);
|
);
|
||||||
$mail_obj->data = [
|
$mail_obj->data = [
|
||||||
'title' => $mail_obj->subject,
|
'title' => $mail_obj->subject,
|
||||||
'message' => ctrans(
|
'content' => ctrans(
|
||||||
$this->template_body,
|
$this->template_body,
|
||||||
[
|
[
|
||||||
'amount' => $mail_obj->amount,
|
'amount' => $mail_obj->amount,
|
||||||
@ -98,7 +98,7 @@ class EntitySentObject
|
|||||||
$mail_obj->markdown = 'email.admin.generic';
|
$mail_obj->markdown = 'email.admin.generic';
|
||||||
$mail_obj->tag = $this->company->company_key;
|
$mail_obj->tag = $this->company->company_key;
|
||||||
}
|
}
|
||||||
|
nlog($mail_obj);
|
||||||
return $mail_obj;
|
return $mail_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class EntitySentObject
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => $this->getSubject(),
|
'title' => $this->getSubject(),
|
||||||
'message' => $this->getMessage(),
|
'content' => $this->getMessage(),
|
||||||
'url' => $this->invitation->getAdminLink($this->use_react_url),
|
'url' => $this->invitation->getAdminLink($this->use_react_url),
|
||||||
'button' => ctrans("texts.view_{$this->entity_type}"),
|
'button' => ctrans("texts.view_{$this->entity_type}"),
|
||||||
'signature' => $settings->email_signature,
|
'signature' => $settings->email_signature,
|
||||||
|
@ -11,8 +11,10 @@
|
|||||||
|
|
||||||
namespace App\Services\Credit;
|
namespace App\Services\Credit;
|
||||||
|
|
||||||
use App\Jobs\Entity\EmailEntity;
|
use App\Utils\Ninja;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
|
use App\Jobs\Entity\EmailEntity;
|
||||||
|
use App\Events\Credit\CreditWasEmailed;
|
||||||
|
|
||||||
class SendEmail
|
class SendEmail
|
||||||
{
|
{
|
||||||
@ -40,12 +42,17 @@ class SendEmail
|
|||||||
$this->reminder_template = $this->credit->calculateTemplate('credit');
|
$this->reminder_template = $this->credit->calculateTemplate('credit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->credit->service()->markSent()->save();
|
||||||
|
|
||||||
$this->credit->invitations->each(function ($invitation) {
|
$this->credit->invitations->each(function ($invitation) {
|
||||||
if (! $invitation->contact->trashed() && $invitation->contact->email) {
|
if (! $invitation->contact->trashed() && $invitation->contact->email) {
|
||||||
EmailEntity::dispatch($invitation, $invitation->company, $this->reminder_template)->delay(2);
|
EmailEntity::dispatch($invitation, $invitation->company, $this->reminder_template)->delay(2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->credit->service()->markSent()->save();
|
if ($this->credit->invitations->count() >= 1) {
|
||||||
|
event(new CreditWasEmailed($this->credit->invitations->first(), $this->credit->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), 'credit'));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,10 @@
|
|||||||
|
|
||||||
namespace App\Services\Quote;
|
namespace App\Services\Quote;
|
||||||
|
|
||||||
use App\Jobs\Entity\EmailEntity;
|
use App\Utils\Ninja;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
|
use App\Jobs\Entity\EmailEntity;
|
||||||
|
use App\Events\Quote\QuoteWasEmailed;
|
||||||
|
|
||||||
class SendEmail
|
class SendEmail
|
||||||
{
|
{
|
||||||
@ -42,15 +44,15 @@ class SendEmail
|
|||||||
$this->reminder_template = $this->quote->calculateTemplate('quote');
|
$this->reminder_template = $this->quote->calculateTemplate('quote');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->quote->service()->markSent()->save();
|
$this->quote->service()->markSent()->save();
|
||||||
|
|
||||||
$this->quote->invitations->each(function ($invitation) {
|
$this->quote->invitations->each(function ($invitation) {
|
||||||
if (! $invitation->contact->trashed() && $invitation->contact->email) {
|
if (! $invitation->contact->trashed() && $invitation->contact->email) {
|
||||||
EmailEntity::dispatch($invitation, $invitation->company, $this->reminder_template);
|
EmailEntity::dispatch($invitation, $invitation->company, $this->reminder_template);
|
||||||
|
|
||||||
// MailEntity::dispatch($invitation, $invitation->company->db, $mo);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user