mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
6a7079b0be
* Update phpunit.yml * Update phpunit.yml * Update .env.ci * Update phpunit.yml * Update .env.ci * Update phpunit.yml * Update phpunit.yml * Update phpunit.yml * Update phpunit.yml * Update .env.ci * Update phpunit.yml * Update phpunit.yml * Update phpunit.yml * Update phpunit.yml * Force /setup if system requirements are not met * Update .env.ci * Update phpunit.yml * Minor changes for github actions" * Fixes for github actions * Fixes for github actions * Fixes for github actions * Fixes for github actions * Fixes for github actions * Fixes for github actions * Fixes for github actions * Fixes for github actions * cs-fixer * cs-fixer * Fixes for github actions * db ports github actions * Refactor the template engine
82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\Invoice;
|
|
|
|
use App\Events\Invoice\InvoiceWasEmailed;
|
|
use App\Events\Invoice\InvoiceWasEmailedAndFailed;
|
|
use App\Helpers\Email\InvoiceEmail;
|
|
use App\Jobs\Utils\SystemLogger;
|
|
use App\Libraries\MultiDB;
|
|
use App\Mail\TemplateEmail;
|
|
use App\Models\Company;
|
|
use App\Models\Invoice;
|
|
use App\Models\InvoiceInvitation;
|
|
use App\Models\SystemLog;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Symfony\Component\Mime\Test\Constraint\EmailTextBodyContains;
|
|
|
|
class EmailInvoice implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public $invoice_invitation;
|
|
|
|
public $email_builder;
|
|
|
|
public $company;
|
|
/**
|
|
*
|
|
* EmailQuote constructor.
|
|
* @param BuildEmail $email_builder
|
|
* @param QuoteInvitation $quote_invitation
|
|
*/
|
|
|
|
public function __construct(InvoiceEmail $email_builder, InvoiceInvitation $invoice_invitation, Company $company)
|
|
{
|
|
$this->company = $company;
|
|
|
|
$this->invoice_invitation = $invoice_invitation;
|
|
|
|
$this->email_builder = $email_builder;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
*
|
|
* @return void
|
|
*/
|
|
|
|
public function handle()
|
|
{
|
|
Mail::to($this->invoice_invitation->contact->email, $this->invoice_invitation->contact->present()->name())
|
|
->send(
|
|
new TemplateEmail(
|
|
$this->email_builder,
|
|
$this->invoice_invitation->contact->user,
|
|
$this->invoice_invitation->contact->client
|
|
)
|
|
);
|
|
|
|
if (count(Mail::failures()) > 0) {
|
|
return $this->logMailError(Mail::failures());
|
|
}
|
|
}
|
|
|
|
private function logMailError($errors)
|
|
{
|
|
SystemLogger::dispatch(
|
|
$errors,
|
|
SystemLog::CATEGORY_MAIL,
|
|
SystemLog::EVENT_MAIL_SEND,
|
|
SystemLog::TYPE_FAILURE,
|
|
$this->invoice->client
|
|
);
|
|
}
|
|
}
|