mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improve custom label replacements in emails
This commit is contained in:
parent
6747d02779
commit
89a271e59c
@ -77,8 +77,13 @@ class EmailPayment implements ShouldQueue
|
|||||||
|
|
||||||
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
|
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
|
||||||
|
|
||||||
|
$invitation = null;
|
||||||
|
|
||||||
|
if($this->payment->invoices()->exists())
|
||||||
|
$invitation = $this->payment->invoices()->first()->invitations()->first();
|
||||||
|
|
||||||
$nmo = new NinjaMailerObject;
|
$nmo = new NinjaMailerObject;
|
||||||
$nmo->mailable = new TemplateEmail($email_builder, $this->contact);
|
$nmo->mailable = new TemplateEmail($email_builder, $this->contact, $invitation);
|
||||||
$nmo->to_user = $this->contact;
|
$nmo->to_user = $this->contact;
|
||||||
$nmo->settings = $this->settings;
|
$nmo->settings = $this->settings;
|
||||||
$nmo->company = $this->company;
|
$nmo->company = $this->company;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Mail\Admin;
|
namespace App\Mail\Admin;
|
||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Utils\HtmlEngine;
|
||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
@ -84,6 +85,8 @@ class AutoBillingFailureObject
|
|||||||
private function getData()
|
private function getData()
|
||||||
{
|
{
|
||||||
$signature = $this->client->getSetting('email_signature');
|
$signature = $this->client->getSetting('email_signature');
|
||||||
|
$html_variables = (new HtmlEngine($this->invoices->first()->invitations->first()))->makeValues();
|
||||||
|
$signature = str_replace(array_keys($html_variables), array_values($html_variables), $signature);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'title' => ctrans(
|
'title' => ctrans(
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Mail\Admin;
|
namespace App\Mail\Admin;
|
||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Utils\HtmlEngine;
|
||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
@ -88,6 +89,8 @@ class ClientPaymentFailureObject
|
|||||||
private function getData()
|
private function getData()
|
||||||
{
|
{
|
||||||
$signature = $this->client->getSetting('email_signature');
|
$signature = $this->client->getSetting('email_signature');
|
||||||
|
$html_variables = (new HtmlEngine($this->invoices->first()->invitations->first()))->makeValues();
|
||||||
|
$signature = str_replace(array_keys($html_variables), array_values($html_variables), $signature);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'title' => ctrans(
|
'title' => ctrans(
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Mail\Admin;
|
namespace App\Mail\Admin;
|
||||||
|
|
||||||
|
use App\Utils\HtmlEngine;
|
||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
@ -121,6 +122,10 @@ class EntityFailedSendObject
|
|||||||
private function getData()
|
private function getData()
|
||||||
{
|
{
|
||||||
$settings = $this->entity->client->getMergedSettings();
|
$settings = $this->entity->client->getMergedSettings();
|
||||||
|
$signature = $settings->email_signature;
|
||||||
|
|
||||||
|
$html_variables = (new HtmlEngine($this->invitation)->makeValues();
|
||||||
|
$signature = str_replace(array_keys($html_variables), array_values($html_variables), $signature);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => $this->getSubject(),
|
'title' => $this->getSubject(),
|
||||||
@ -136,7 +141,7 @@ class EntityFailedSendObject
|
|||||||
),
|
),
|
||||||
'url' => $this->invitation->getAdminLink(),
|
'url' => $this->invitation->getAdminLink(),
|
||||||
'button' => ctrans("texts.view_{$this->entity_type}"),
|
'button' => ctrans("texts.view_{$this->entity_type}"),
|
||||||
'signature' => $settings->email_signature,
|
'signature' => $signature,
|
||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Mail\Admin;
|
namespace App\Mail\Admin;
|
||||||
|
|
||||||
|
use App\Mail\Engine\PaymentEmailEngine;
|
||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
@ -62,6 +63,8 @@ class EntityPaidObject
|
|||||||
{
|
{
|
||||||
$settings = $this->payment->client->getMergedSettings();
|
$settings = $this->payment->client->getMergedSettings();
|
||||||
|
|
||||||
|
$signature = $this->generateSignature($settings);
|
||||||
|
|
||||||
$amount = Number::formatMoney($this->payment->amount, $this->payment->client);
|
$amount = Number::formatMoney($this->payment->amount, $this->payment->client);
|
||||||
|
|
||||||
$invoice_texts = ctrans('texts.invoice_number_short');
|
$invoice_texts = ctrans('texts.invoice_number_short');
|
||||||
@ -85,7 +88,6 @@ class EntityPaidObject
|
|||||||
]
|
]
|
||||||
),
|
),
|
||||||
'url' => config('ninja.app_url'),
|
'url' => config('ninja.app_url'),
|
||||||
// 'url' => config('ninja.app_url') . '/payments/' . $this->payment->hashed_id, //because we have no deep linking we cannot use this
|
|
||||||
'button' => ctrans('texts.view_payment'),
|
'button' => ctrans('texts.view_payment'),
|
||||||
'signature' => $settings->email_signature,
|
'signature' => $settings->email_signature,
|
||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
@ -95,4 +97,13 @@ class EntityPaidObject
|
|||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function generateSignature($settings)
|
||||||
|
{
|
||||||
|
$html_variables = (new PaymentEmailEngine($this->payment, $this->payment->client->primary_contact()->first()))->makeValues();
|
||||||
|
|
||||||
|
$signature = str_replace(array_keys($html_variables), array_values($html_variables), $settings->email_signature);
|
||||||
|
|
||||||
|
return $signature;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ class BaseEmailEngine implements EngineInterface
|
|||||||
{
|
{
|
||||||
if (! empty($this->variables)) {
|
if (! empty($this->variables)) {
|
||||||
$body = str_replace(array_keys($this->variables), array_values($this->variables), $body);
|
$body = str_replace(array_keys($this->variables), array_values($this->variables), $body);
|
||||||
|
$body = str_replace(array_keys($this->variables), array_values($this->variables), $body);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->body = $body;
|
$this->body = $body;
|
||||||
|
@ -76,7 +76,7 @@ class PaymentEmailEngine extends BaseEmailEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function makePaymentVariables()
|
public function makePaymentVariables()
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
@ -53,9 +53,14 @@ class TemplateEmail extends Mailable
|
|||||||
|
|
||||||
$company = $this->client->company;
|
$company = $this->client->company;
|
||||||
|
|
||||||
$html_variables = (new HtmlEngine($this->invitation))->makeValues();
|
if($this->invitation)
|
||||||
|
{
|
||||||
//str_replace(array_keys($html_variables), array_values($html_variables), $settings->email_signature)
|
$html_variables = (new HtmlEngine($this->invitation))->makeValues();
|
||||||
|
$signature = str_replace(array_keys($html_variables), array_values($html_variables), $settings->email_signature);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$signature = $settings->email_signature;
|
||||||
|
|
||||||
$this->from(config('mail.from.address'), $this->company->present()->name());
|
$this->from(config('mail.from.address'), $this->company->present()->name());
|
||||||
|
|
||||||
if (strlen($settings->bcc_email) > 1)
|
if (strlen($settings->bcc_email) > 1)
|
||||||
@ -75,7 +80,7 @@ class TemplateEmail extends Mailable
|
|||||||
'view_link' => $this->build_email->getViewLink(),
|
'view_link' => $this->build_email->getViewLink(),
|
||||||
'view_text' => $this->build_email->getViewText(),
|
'view_text' => $this->build_email->getViewText(),
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'signature' => str_replace(array_keys($html_variables), array_values($html_variables), $settings->email_signature),
|
'signature' => $signature,
|
||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'company' => $company,
|
'company' => $company,
|
||||||
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user