diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 4ba7bd5cd12f..6c9a9217a0bc 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -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('
', $this->build_email->getBody(), $settings) - ); } $company = $this->client->company; diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index 0b6621b7af05..83359064ac7b 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -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('
', ['$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) ? '
' : mb_convert_encoding((new CssToInlineStyles())->convert($body, $styles), 'HTML-ENTITIES', 'UTF-8')); - - $table_html =' - - - - - - -
-
-
'; - - 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')); - } } diff --git a/resources/lang/en_GB/texts.php b/resources/lang/en_GB/texts.php index 37e6ad6523e9..5f96e3c387af 100644 --- a/resources/lang/en_GB/texts.php +++ b/resources/lang/en_GB/texts.php @@ -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)', diff --git a/resources/views/email/client/generic.blade.php b/resources/views/email/client/generic.blade.php index ebf74c1c4e98..4cbe538a67fb 100644 --- a/resources/views/email/client/generic.blade.php +++ b/resources/views/email/client/generic.blade.php @@ -25,7 +25,7 @@ @endisset @isset($signature) - {!! $signature !!} + {!! nl2br($signature) !!} @endisset @endcomponent diff --git a/resources/views/email/template/client.blade.php b/resources/views/email/template/client.blade.php index 512ee8dd23be..d00761ef10bc 100644 --- a/resources/views/email/template/client.blade.php +++ b/resources/views/email/template/client.blade.php @@ -90,6 +90,10 @@ #content .center { text-align: center; } + + #content .left { + text-align: left !important; + } @@ -116,15 +120,11 @@ -
+
{{ $slot ?? '' }} {!! $body ?? '' !!} - - @isset($signature) - {{ nl2br($signature) }} - @endisset
- @if(isset($company) && $company instanceof \App\Models\Company)
-

- {{ ctrans('texts.client_email_company_contact_label') }} -

-

- {{ $company->present()->name() }}

-

- {{ $company->settings->phone }} - {{ $company->settings->website }} -

+ @isset($signature) +

+ {!! nl2br($signature) !!} +

+ @endisset + + @if(isset($company) && $company instanceof \App\Models\Company) +

+ {{ $company->present()->name() }}

+

+ {{ $company->settings->phone }} + {{ $company->settings->website }} +

+ @endif
- @endif