1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/app/Services/Quote/SendEmail.php

58 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2020-07-01 03:06:40 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2020-07-01 03:06:40 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2024-04-12 06:15:41 +02:00
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
2020-07-01 03:06:40 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2020-07-01 03:06:40 +02:00
*/
namespace App\Services\Quote;
2023-12-12 08:43:55 +01:00
use App\Models\Webhook;
2023-10-26 04:57:44 +02:00
use App\Models\ClientContact;
2023-12-12 08:43:55 +01:00
use App\Jobs\Entity\EmailEntity;
2023-03-13 20:59:11 +01:00
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.
2020-10-28 11:10:49 +01:00
* @return void
*/
2020-08-19 04:55:58 +02:00
public function run()
{
2023-02-15 01:04:47 +01:00
if (! $this->reminder_template) {
2020-10-27 12:57:12 +01:00
$this->reminder_template = $this->quote->calculateTemplate('quote');
}
2023-02-15 01:04:47 +01:00
2022-07-27 07:39:43 +02:00
$this->quote->service()->markSent()->save();
2023-03-18 08:24:56 +01:00
$this->quote->invitations->each(function ($invitation) {
if (! $invitation->contact->trashed() && $invitation->contact->email) {
2023-02-15 12:31:02 +01:00
EmailEntity::dispatch($invitation, $invitation->company, $this->reminder_template);
}
});
2023-09-07 04:07:46 +02:00
2023-12-12 08:43:55 +01:00
$this->quote->sendEvent(Webhook::EVENT_SENT_QUOTE, "client");
2023-09-07 04:07:46 +02:00
}
}