mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #5505 from beganovich/v5-2104-emails
(v5) Fixes for emails
This commit is contained in:
commit
3c5a70cd21
@ -55,15 +55,17 @@ class TemplateEmail extends Mailable
|
||||
$this->build_email->setBody(str_replace('$body', $this->build_email->getBody(), $this->client->getSetting('email_style_custom')));
|
||||
}
|
||||
|
||||
$this->build_email->setBody(
|
||||
DesignHelpers::parseMarkdownToHtml($this->build_email->getBody())
|
||||
);
|
||||
|
||||
$settings = $this->client->getMergedSettings();
|
||||
|
||||
$this->build_email->setBody(
|
||||
TemplateEngine::wrapElementsIntoTables('<div id="content-wrapper"></div>', $this->build_email->getBody(), $settings)
|
||||
);
|
||||
if ($this->build_email->getTemplate() !== 'custom') {
|
||||
$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;
|
||||
|
||||
|
@ -52,6 +52,10 @@ class TemplateEngine
|
||||
private $raw_body;
|
||||
|
||||
private $raw_subject;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $labels_and_values;
|
||||
|
||||
public function __construct($body, $subject, $entity, $entity_id, $template)
|
||||
{
|
||||
@ -165,17 +169,20 @@ class TemplateEngine
|
||||
|
||||
private function entityValues($contact)
|
||||
{
|
||||
$this->labels_and_values = (new HtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
||||
|
||||
$data = (new HtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
||||
|
||||
$this->body = strtr($this->body, $data['labels']);
|
||||
$this->body = strtr($this->body, $data['values']);
|
||||
$this->body = strtr($this->body, $this->labels_and_values['labels']);
|
||||
$this->body = strtr($this->body, $this->labels_and_values['values']);
|
||||
// $this->body = str_replace("\n", "<br>", $this->body);
|
||||
|
||||
$this->subject = strtr($this->subject, $data['labels']);
|
||||
$this->subject = strtr($this->subject, $data['values']);
|
||||
$this->subject = strtr($this->subject, $this->labels_and_values['labels']);
|
||||
$this->subject = strtr($this->subject, $this->labels_and_values['values']);
|
||||
|
||||
$this->body = DesignHelpers::parseMarkdownToHtml($this->body);
|
||||
$email_style = $this->settings_entity->getSetting('email_style');
|
||||
|
||||
if ($email_style !== 'custom') {
|
||||
$this->body = DesignHelpers::parseMarkdownToHtml($this->body);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderTemplate()
|
||||
@ -192,6 +199,11 @@ class TemplateEngine
|
||||
if ($email_style == 'custom') {
|
||||
$wrapper = $this->settings_entity->getSetting('email_style_custom');
|
||||
|
||||
// In order to parse variables such as $signature in the body,
|
||||
// we need to replace strings with the values from HTMLEngine.
|
||||
|
||||
$wrapper = strtr($wrapper, $this->labels_and_values['values']);
|
||||
|
||||
/*If no custom design exists, send back a blank!*/
|
||||
if (strlen($wrapper) > 1) {
|
||||
$wrapper = $this->renderView($wrapper, $data);
|
||||
@ -206,7 +218,7 @@ class TemplateEngine
|
||||
|
||||
$data = [
|
||||
'subject' => $this->subject,
|
||||
'body' => self::wrapElementsIntoTables(strtr($wrapper, ['$body' => '']), $this->body, $this->entity_obj->client->getMergedSettings()),
|
||||
'body' => $email_style == 'custom' ? $this->body : self::wrapElementsIntoTables(strtr('<div id="content-wrapper"></div>', ['$body' => '']), $this->body, $this->entity_obj->client->getMergedSettings()),
|
||||
'wrapper' => $wrapper,
|
||||
'raw_body' => $this->raw_body,
|
||||
'raw_subject' => $this->raw_subject
|
||||
@ -263,7 +275,7 @@ class TemplateEngine
|
||||
public static function wrapElementsIntoTables(string $wrapper, string $body, $settings): ?string
|
||||
{
|
||||
$documents['wrapper'] = new \DOMDocument();
|
||||
$documents['wrapper']->loadHTML($wrapper);
|
||||
@$documents['wrapper']->loadHTML($wrapper);
|
||||
|
||||
$documents['master'] = new \DOMDocument();
|
||||
|
||||
|
@ -224,11 +224,15 @@
|
||||
<div class="u-col u-col-100" style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
|
||||
<div style="width: 100% !important;">
|
||||
<!--[if (!mso)&(!IE)]><!--><div style="padding: 11px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;"><!--<![endif]-->
|
||||
<div id="content-wrapper">
|
||||
<div class="content-contrast-color">
|
||||
@yield('greeting')
|
||||
</div>
|
||||
|
||||
<div id="content-wrapper">
|
||||
{{ $slot }}
|
||||
</div>
|
||||
|
||||
<div class="content-contrast-color">
|
||||
@yield('signature')
|
||||
@yield('footer')
|
||||
</div>
|
||||
|
@ -8,47 +8,24 @@
|
||||
<title>Invoice Ninja</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table role="presentation" cellpadding="0" cellspacing="0" width="100%">
|
||||
<div id="content-wrapper">
|
||||
{!! $body !!}
|
||||
</div>
|
||||
|
||||
@if($signature)
|
||||
<tr>
|
||||
<td style="font-family: Arial, sans-serif, 'Open Sans'">
|
||||
<table cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<table cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td id="email-content">
|
||||
{!! $body !!}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
@if($signature)
|
||||
<tr>
|
||||
<td>
|
||||
<p>{!! $signature !!}</p>
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
@isset($whitelabel)
|
||||
@if(!$whitelabel)
|
||||
<td>
|
||||
<p>
|
||||
<a href="https://invoiceninja.com" target="_blank">
|
||||
{{ __('texts.ninja_email_footer', ['site' => 'Invoice Ninja']) }}
|
||||
</a>
|
||||
</p>
|
||||
</td>
|
||||
@endif
|
||||
@endif
|
||||
</tr>
|
||||
</table>
|
||||
<td>
|
||||
<p>{!! $signature !!}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@endif
|
||||
|
||||
@isset($whitelabel)
|
||||
@if(!$whitelabel)
|
||||
<p>
|
||||
<a href="https://invoiceninja.com" target="_blank">
|
||||
{{ __('texts.ninja_email_footer', ['site' => 'Invoice Ninja']) }}
|
||||
</a>
|
||||
</p>
|
||||
@endif
|
||||
@endisset
|
||||
|
Loading…
x
Reference in New Issue
Block a user