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

63 lines
2.2 KiB
PHP
Raw Normal View History

2021-02-14 21:55:09 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2021-02-14 21:55:09 +01:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-02-14 21:55:09 +01:00
*/
namespace App\Mail\RecurringInvoice;
use App\Models\ClientContact;
2023-10-26 04:57:44 +02:00
use App\Models\Company;
use App\Models\RecurringInvoice;
2023-10-26 04:57:44 +02:00
use App\Utils\Ninja;
2021-06-29 11:46:40 +02:00
use Illuminate\Support\Facades\App;
2021-02-14 21:55:09 +01:00
class ClientContactRequestCancellationObject
{
2023-08-02 11:47:26 +02:00
public Company $company;
2023-02-16 02:36:09 +01:00
public function __construct(public RecurringInvoice $recurring_invoice, public ClientContact $client_contact, private bool $gateway_refund_attempted)
{
}
2021-02-14 21:55:09 +01:00
public function build()
{
$this->company = $this->recurring_invoice->company;
2021-06-29 11:46:40 +02:00
App::forgetInstance('translator');
2022-01-15 05:07:40 +01:00
App::setLocale($this->company->getLocale());
2021-06-29 11:46:40 +02:00
$t = app('translator');
$t->replace(Ninja::transformTranslations($this->company->settings));
$content = ctrans('texts.recurring_cancellation_request_body', ['contact' => $this->client_contact->present()->name(), 'client' => $this->client_contact->client->present()->name(), 'invoice' => $this->recurring_invoice->number]);
2023-02-16 02:36:09 +01:00
if ($this->gateway_refund_attempted) {
$content .= "\n\n" . ctrans('texts.status') . " : " . ctrans('texts.payment_status_6');
2023-02-16 02:36:09 +01:00
}
2021-06-29 11:46:40 +02:00
2021-02-14 21:55:09 +01:00
$data = [
'title' => ctrans('texts.recurring_cancellation_request', ['contact' => $this->client_contact->present()->name()]),
'content' => $content,
2021-02-14 21:55:09 +01:00
'url' => config('ninja.web_url'),
'button' => ctrans('texts.account_login'),
'signature' => $this->company->settings->email_signature,
'settings' => $this->company->settings,
'logo' => $this->company->present()->logo(),
];
$mail_obj = new \stdClass;
2021-02-14 22:32:59 +01:00
$mail_obj->subject = ctrans('texts.recurring_cancellation_request', ['contact' => $this->client_contact->present()->name()]);
2021-02-14 21:55:09 +01:00
$mail_obj->data = $data;
$mail_obj->markdown = 'email.admin.generic';
$mail_obj->tag = $this->company->company_key;
2022-03-04 04:01:09 +01:00
$mail_obj->text_view = 'email.admin.generic_text';
2021-02-14 21:55:09 +01:00
return $mail_obj;
}
}