mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
d9d2e21f93
* Working on subscriptions * Implement return type in models * Subscription implementation * Improvements to handling importation of large accountS * Loggin imports * Activate collector * Improve memory usage of import script * Quote actions * Send Quotes * Fixes for seg faults! * Minor fixes * Fixes for client contact scopes
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Quote;
|
|
|
|
use App\Helpers\Email\QuoteEmail;
|
|
use App\Jobs\Quote\EmailQuote;
|
|
use App\Models\ClientContact;
|
|
use App\Models\Quote;
|
|
|
|
class SendEmail
|
|
{
|
|
public $quote;
|
|
|
|
protected $reminder_template;
|
|
|
|
protected $contact;
|
|
|
|
public function __construct($quote, $reminder_template = null, ClientContact $contact = null)
|
|
{
|
|
$this->quote = $quote;
|
|
|
|
$this->reminder_template = $reminder_template;
|
|
|
|
$this->contact = $contact;
|
|
}
|
|
|
|
/**
|
|
* Builds the correct template to send
|
|
* @param string $this->reminder_template The template name ie reminder1
|
|
* @return array
|
|
*/
|
|
public function run(): array
|
|
{
|
|
if (!$this->reminder_template) {
|
|
$this->reminder_template = $this->quote->calculateTemplate();
|
|
}
|
|
|
|
$this->quote->invitations->each(function ($invitation) {
|
|
if ($invitation->contact->send_email && $invitation->contact->email) {
|
|
$email_builder = (new QuoteEmail())->build($invitation, $this->reminder_template);
|
|
|
|
EmailQuote::dispatchNow($email_builder, $invitation);
|
|
}
|
|
});
|
|
}
|
|
}
|