mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 16:54:36 -04:00
Merge pull request #6116 from beganovich/v5-2306-swap-bottom-text-for-signature
(v5) E-mail improvements
This commit is contained in:
commit
cb338141eb
@ -49,8 +49,11 @@ class TemplateEmail extends Mailable
|
||||
|
||||
public function build()
|
||||
{
|
||||
// $template_name = 'email.template.'.$this->build_email->getTemplate();
|
||||
$template_name = 'email.template.client';
|
||||
$template_name = 'email.template.'.$this->build_email->getTemplate();
|
||||
|
||||
if ($this->build_email->getTemplate() == 'light' || $this->build_email->getTemplate() == 'dark') {
|
||||
$template_name = 'email.template.client';
|
||||
}
|
||||
|
||||
if($this->build_email->getTemplate() == 'custom') {
|
||||
$this->build_email->setBody(str_replace('$body', $this->build_email->getBody(), $this->client->getSetting('email_style_custom')));
|
||||
@ -62,10 +65,6 @@ class TemplateEmail extends Mailable
|
||||
$this->build_email->setBody(
|
||||
DesignHelpers::parseMarkdownToHtml($this->build_email->getBody())
|
||||
);
|
||||
|
||||
$this->build_email->setBody(
|
||||
TemplateEngine::wrapElementsIntoTables('<div id="content-wrapper"></div>', $this->build_email->getBody(), $settings)
|
||||
);
|
||||
}
|
||||
|
||||
$company = $this->client->company;
|
||||
|
@ -212,7 +212,7 @@ class TemplateEngine
|
||||
} else {
|
||||
$wrapper = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($email_style == 'plain') {
|
||||
$wrapper = view($this->getTemplatePath($email_style), $data)->render();
|
||||
$injection = '';
|
||||
@ -226,7 +226,7 @@ class TemplateEngine
|
||||
|
||||
$data = [
|
||||
'subject' => $this->subject,
|
||||
'body' => $email_style == 'custom' ? $this->body : self::wrapElementsIntoTables(strtr('<div id="content-wrapper"></div>', ['$body' => '']), $this->body, $this->entity_obj->client->getMergedSettings()),
|
||||
'body' => $this->body,
|
||||
'wrapper' => $wrapper,
|
||||
'raw_body' => $this->raw_body,
|
||||
'raw_subject' => $this->raw_subject
|
||||
@ -279,50 +279,4 @@ class TemplateEngine
|
||||
{
|
||||
DB::rollBack();
|
||||
}
|
||||
|
||||
public static function wrapElementsIntoTables(string $wrapper, string $body, $settings): ?string
|
||||
{
|
||||
$documents['wrapper'] = new \DOMDocument();
|
||||
@$documents['wrapper']->loadHTML($wrapper);
|
||||
|
||||
$documents['master'] = new \DOMDocument();
|
||||
|
||||
$documents['master']->loadHTML(
|
||||
view('email.template.master', ['header' => '', 'slot' => '', 'settings' => $settings])->render()
|
||||
);
|
||||
|
||||
$styles = $documents['master']->getElementsByTagName('style')->item(0)->nodeValue;
|
||||
|
||||
$documents['wrapper']->saveHTML();
|
||||
|
||||
$documents['body'] = new \DOMDocument();
|
||||
$documents['body']->loadHTML(empty($body) ? '<div></div>' : mb_convert_encoding((new CssToInlineStyles())->convert($body, $styles), 'HTML-ENTITIES', 'UTF-8'));
|
||||
|
||||
$table_html ='
|
||||
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="overflow-wrap:break-word;word-break:break-word;padding:5px;font-family:arial,helvetica,sans-serif;" align="left">
|
||||
<div style="color: #000000; line-height: 140%; text-align: left; word-wrap: break-word;" id="table-content" class="content-contrast-color"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
foreach ($documents['body']->getElementsByTagName('body')->item(0)->childNodes as $element) {
|
||||
$table = new \DOMDocument();
|
||||
|
||||
$table->loadHTML($table_html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||
|
||||
$element = $table->importNode($element, true);
|
||||
|
||||
$table->getElementById('table-content')->appendChild($element);
|
||||
|
||||
$node = $documents['wrapper']->importNode($table->documentElement, true);
|
||||
|
||||
$documents['wrapper']->getElementById('content-wrapper')->appendChild($node);
|
||||
}
|
||||
|
||||
return $documents['wrapper']->getElementById('content-wrapper')->ownerDocument->saveHTML($documents['wrapper']->getElementById('content-wrapper'));
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ $LANG = array(
|
||||
'archived_vendors' => 'Successfully archived :count vendors',
|
||||
'deleted_vendor' => 'Successfully deleted vendor',
|
||||
'deleted_vendors' => 'Successfully deleted :count vendors',
|
||||
'confirmation_subject' => 'Invoice Ninja Account Confirmation',
|
||||
'confirmation_subject' => 'Account Confirmation',
|
||||
'confirmation_header' => 'Account Confirmation',
|
||||
'confirmation_message' => 'Please access the link below to confirm your account.',
|
||||
'invoice_subject' => 'New invoice :number from :account',
|
||||
@ -887,7 +887,7 @@ $LANG = array(
|
||||
'custom_invoice_charges_helps' => 'Add a field when creating an invoice and include the charge in the invoice subtotals.',
|
||||
'token_expired' => 'Validation token was expired. Please try again.',
|
||||
'invoice_link' => 'Invoice Link',
|
||||
'button_confirmation_message' => 'Click to confirm your email address.',
|
||||
'button_confirmation_message' => 'Click to confirm your email.',
|
||||
'confirm' => 'Confirm',
|
||||
'email_preferences' => 'Email Preferences',
|
||||
'created_invoices' => 'Successfully created :count invoice(s)',
|
||||
|
@ -25,7 +25,7 @@
|
||||
@endisset
|
||||
|
||||
@isset($signature)
|
||||
{!! $signature !!}
|
||||
{!! nl2br($signature) !!}
|
||||
@endisset
|
||||
</div>
|
||||
@endcomponent
|
||||
|
@ -90,6 +90,10 @@
|
||||
#content .center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#content .left {
|
||||
text-align: left !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@ -116,15 +120,11 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div style="border: 1px solid #c2c2c2; border-top: none; border-bottom: none; padding: 20px;" id="content">
|
||||
<div style="border: 1px solid #c2c2c2; border-top: none; border-bottom: none; padding: 20px; text-align: center" id="content">
|
||||
<div style="padding-top: 10px;"></div>
|
||||
|
||||
{{ $slot ?? '' }}
|
||||
{!! $body ?? '' !!}
|
||||
|
||||
@isset($signature)
|
||||
{{ nl2br($signature) }}
|
||||
@endisset
|
||||
|
||||
<div>
|
||||
<a href="#"
|
||||
@ -135,24 +135,27 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@if(isset($company) && $company instanceof \App\Models\Company)
|
||||
<tr>
|
||||
<td>
|
||||
<div class="dark-bg dark-text-white"
|
||||
style="text-align: center; padding-top: 10px; padding-bottom: 25px; background-color: #f9f9f9; border: 1px solid #c2c2c2; border-top: none; border-bottom-color: #f9f9f9;">
|
||||
<p style="font-size: 15px; color: #2e2e2e; font-family: 'roboto', Arial, Helvetica, sans-serif; font-weight: 400; margin-bottom: 30px;">
|
||||
{{ ctrans('texts.client_email_company_contact_label') }}
|
||||
</p>
|
||||
<p style="font-size: 15px; color: #2e2e2e; font-family: 'roboto', Arial, Helvetica, sans-serif; font-weight: 500; margin-bottom:0;">
|
||||
{{ $company->present()->name() }}</p>
|
||||
<p style="font-size: 15px; color: #2e2e2e; font-family: 'roboto', Arial, Helvetica, sans-serif; font-weight: 400; margin-top: 5px;">
|
||||
<span>{{ $company->settings->phone }}</span>
|
||||
<span style="font-weight: 500"> {{ $company->settings->website }}</span>
|
||||
</p>
|
||||
@isset($signature)
|
||||
<p style="font-size: 15px; color: #2e2e2e; font-family: 'roboto', Arial, Helvetica, sans-serif; font-weight: 400; margin-bottom: 30px;">
|
||||
{!! nl2br($signature) !!}
|
||||
</p>
|
||||
@endisset
|
||||
|
||||
@if(isset($company) && $company instanceof \App\Models\Company)
|
||||
<p style="font-size: 15px; color: #2e2e2e; font-family: 'roboto', Arial, Helvetica, sans-serif; font-weight: 500; margin-bottom:0;">
|
||||
{{ $company->present()->name() }}</p>
|
||||
<p style="font-size: 15px; color: #2e2e2e; font-family: 'roboto', Arial, Helvetica, sans-serif; font-weight: 400; margin-top: 5px;">
|
||||
<span>{{ $company->settings->phone }}</span>
|
||||
<span style="font-weight: 500"> {{ $company->settings->website }}</span>
|
||||
</p>
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user