mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for plain email templates
This commit is contained in:
parent
6fbaa209a7
commit
7afb9f9bb9
@ -33,6 +33,10 @@ class BaseEmailEngine implements EngineInterface
|
||||
|
||||
public $invitation;
|
||||
|
||||
public $text_body;
|
||||
|
||||
public $text_footer;
|
||||
|
||||
public function setFooter($footer)
|
||||
{
|
||||
$this->footer = $footer;
|
||||
@ -105,6 +109,13 @@ class BaseEmailEngine implements EngineInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTextBody($text)
|
||||
{
|
||||
$this->text_body = $text;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->subject;
|
||||
@ -148,11 +159,37 @@ class BaseEmailEngine implements EngineInterface
|
||||
public function setInvitation($invitation)
|
||||
{
|
||||
$this->invitation = $invitation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getInvitation()
|
||||
{
|
||||
return $this->invitation;
|
||||
}
|
||||
|
||||
public function getTextBody()
|
||||
{
|
||||
return $this->text_body;
|
||||
}
|
||||
|
||||
private function replaceEntities($content)
|
||||
{
|
||||
$find = [
|
||||
'<p>',
|
||||
'</p>',
|
||||
'<div class="center">',
|
||||
'<\div>',
|
||||
];
|
||||
|
||||
$replace = [
|
||||
'',
|
||||
'\n\n',
|
||||
'',
|
||||
'\n\n',
|
||||
];
|
||||
|
||||
return str_replace($find, $replace, $content);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,18 @@ class CreditEmailEngine extends BaseEmailEngine
|
||||
);
|
||||
}
|
||||
|
||||
$text_body = trans(
|
||||
'texts.credit_message',
|
||||
[
|
||||
'credit' => $this->credit->number,
|
||||
'company' => $this->credit->company->present()->name(),
|
||||
'amount' => Number::formatMoney($this->credit->balance, $this->client),
|
||||
],
|
||||
null,
|
||||
$this->client->locale()
|
||||
|
||||
) . "\n\n" . $this->invitation->getLink();
|
||||
|
||||
$this->setTemplate($this->client->getSetting('email_style'))
|
||||
->setContact($this->contact)
|
||||
->setVariables((new HtmlEngine($this->invitation))->makeValues())//move make values into the htmlengine
|
||||
@ -101,7 +113,8 @@ class CreditEmailEngine extends BaseEmailEngine
|
||||
->setFooter("<a href='{$this->invitation->getLink()}'>".ctrans('texts.view_credit').'</a>')
|
||||
->setViewLink($this->invitation->getLink())
|
||||
->setViewText(ctrans('texts.view_credit'))
|
||||
->setInvitation($this->invitation);
|
||||
->setInvitation($this->invitation)
|
||||
->setTextBody($text_body);
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->credit->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||
|
||||
|
@ -46,4 +46,7 @@ interface EngineInterface
|
||||
public function getViewText();
|
||||
|
||||
public function build();
|
||||
|
||||
public function getTextBody();
|
||||
|
||||
}
|
||||
|
@ -79,6 +79,17 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
||||
|
||||
}
|
||||
|
||||
$text_body = trans(
|
||||
'texts.invoice_message',
|
||||
[
|
||||
'invoice' => $this->invoice->number,
|
||||
'company' => $this->invoice->company->present()->name(),
|
||||
'amount' => Number::formatMoney($this->invoice->balance, $this->client),
|
||||
],
|
||||
null,
|
||||
$this->client->locale()
|
||||
) . "\n\n" . $this->invitation->getLink();
|
||||
|
||||
if (is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) {
|
||||
$subject_template = $this->template_data['subject'];
|
||||
nlog("subject = template data");
|
||||
@ -111,7 +122,8 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
||||
->setFooter("<a href='{$this->invitation->getLink()}'>".ctrans('texts.view_invoice').'</a>')
|
||||
->setViewLink($this->invitation->getLink())
|
||||
->setViewText(ctrans('texts.view_invoice'))
|
||||
->setInvitation($this->invitation);
|
||||
->setInvitation($this->invitation)
|
||||
->setTextBody($text_body);
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->invoice->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||
|
||||
|
@ -94,6 +94,18 @@ class QuoteEmailEngine extends BaseEmailEngine
|
||||
);
|
||||
}
|
||||
|
||||
$text_body = trans(
|
||||
'texts.quote_message',
|
||||
[
|
||||
'quote' => $this->quote->number,
|
||||
'company' => $this->quote->company->present()->name(),
|
||||
'amount' => Number::formatMoney($this->quote->amount, $this->client),
|
||||
],
|
||||
null,
|
||||
$this->client->locale()
|
||||
|
||||
) . "\n\n" . $this->invitation->getLink();
|
||||
|
||||
$this->setTemplate($this->client->getSetting('email_style'))
|
||||
->setContact($this->contact)
|
||||
->setVariables((new HtmlEngine($this->invitation))->makeValues())//move make values into the htmlengine
|
||||
@ -102,7 +114,8 @@ class QuoteEmailEngine extends BaseEmailEngine
|
||||
->setFooter("<a href='{$this->invitation->getLink()}'>".ctrans('texts.view_quote').'</a>')
|
||||
->setViewLink($this->invitation->getLink())
|
||||
->setViewText(ctrans('texts.view_quote'))
|
||||
->setInvitation($this->invitation);
|
||||
->setInvitation($this->invitation)
|
||||
->setTextBody($text_body);
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->quote->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||
|
||||
|
@ -92,12 +92,10 @@ class TemplateEmail extends Mailable
|
||||
$this->bcc(explode(",",str_replace(" ", "", $settings->bcc_email)));//remove whitespace if any has been inserted.
|
||||
|
||||
$this->subject($this->build_email->getSubject())
|
||||
->text('email.template.plain', [
|
||||
'body' => $this->build_email->getBody(),
|
||||
'footer' => $this->build_email->getFooter(),
|
||||
->text('email.template.text', [
|
||||
'text_body' => $this->build_email->getTextBody(),
|
||||
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
||||
'settings' => $settings,
|
||||
'unsubscribe_link' => $this->invitation ? $this->invitation->getUnsubscribeLink() : '',
|
||||
])
|
||||
->view($template_name, [
|
||||
'greeting' => ctrans('texts.email_salutation', ['name' => $this->contact->present()->name()]),
|
||||
@ -111,7 +109,6 @@ class TemplateEmail extends Mailable
|
||||
'company' => $company,
|
||||
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
||||
'logo' => $this->company->present()->logo($settings),
|
||||
'unsubscribe_link' => $this->invitation ? $this->invitation->getUnsubscribeLink() : '',
|
||||
])
|
||||
->withSwiftMessage(function ($message) use($company){
|
||||
$message->getHeaders()->addTextHeader('Tag', $company->company_key);
|
||||
|
@ -26,7 +26,7 @@
|
||||
],
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": "^7.4|^8",
|
||||
"php": "^8.0",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-libxml": "*",
|
||||
@ -64,6 +64,7 @@
|
||||
"league/flysystem-aws-s3-v3": "~1.0",
|
||||
"league/flysystem-cached-adapter": "^1.1",
|
||||
"league/fractal": "^0.17.0",
|
||||
"league/html-to-markdown": "^5.1",
|
||||
"league/omnipay": "^3.1",
|
||||
"livewire/livewire": "^2.6",
|
||||
"mollie/mollie-api-php": "^2.36",
|
||||
|
1399
composer.lock
generated
1399
composer.lock
generated
File diff suppressed because it is too large
Load Diff
10
resources/views/email/admin/download_credits.blade.php
Normal file
10
resources/views/email/admin/download_credits.blade.php
Normal file
@ -0,0 +1,10 @@
|
||||
@component('email.template.admin', ['logo' => $logo, 'settings' => $settings])
|
||||
<div class="center">
|
||||
<h1>{{ ctrans('texts.credits_backup_subject') }}</h1>
|
||||
<p>{{ ctrans('texts.download_timeframe') }}</p>
|
||||
|
||||
<a target="_blank" class="button" href="{{ $url }}">
|
||||
{{ ctrans('texts.download') }}
|
||||
</a>
|
||||
</div>
|
||||
@endcomponent
|
10
resources/views/email/admin/download_quotes.blade.php
Normal file
10
resources/views/email/admin/download_quotes.blade.php
Normal file
@ -0,0 +1,10 @@
|
||||
@component('email.template.admin', ['logo' => $logo, 'settings' => $settings])
|
||||
<div class="center">
|
||||
<h1>{{ ctrans('texts.quotes_backup_subject') }}</h1>
|
||||
<p>{{ ctrans('texts.download_timeframe') }}</p>
|
||||
|
||||
<a target="_blank" class="button" href="{{ $url }}">
|
||||
{{ ctrans('texts.download') }}
|
||||
</a>
|
||||
</div>
|
||||
@endcomponent
|
@ -177,9 +177,6 @@
|
||||
</p>
|
||||
@endif
|
||||
</div>
|
||||
@if(isset($unsubscribe_link))
|
||||
<p><a href="{{$unsubscribe_link}}">{{ ctrans('texts.unsubscribe') }}</a></p>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
7
resources/views/email/template/text.blade.php
Normal file
7
resources/views/email/template/text.blade.php
Normal file
@ -0,0 +1,7 @@
|
||||
{!! $text_body !!}
|
||||
@isset($whitelabel)
|
||||
@if(!$whitelabel)
|
||||
|
||||
{{ ctrans('texts.ninja_email_footer', ['site' => 'https://invoiceninja.com']) }}
|
||||
@endif
|
||||
@endisset
|
Loading…
x
Reference in New Issue
Block a user