fixes for custom email templates

This commit is contained in:
David Bomba 2024-05-21 11:40:12 +10:00
parent c166ef82ff
commit e01f100407
7 changed files with 16 additions and 14 deletions

View File

@ -136,8 +136,8 @@ class NinjaMailerJob implements ShouldQueue
$mailable = $this->nmo->mailable; $mailable = $this->nmo->mailable;
/** May need to re-build it here */ /** May need to re-build it here @todo explain why we need this? */
if (Ninja::isHosted() && method_exists($mailable, 'build')) { if (Ninja::isHosted() && method_exists($mailable, 'build') && $this->nmo->settings->email_style != "custom") {
$mailable->build(); $mailable->build();
} }
@ -675,9 +675,6 @@ class NinjaMailerJob implements ShouldQueue
*/ */
private function preFlightChecksFail(): bool private function preFlightChecksFail(): bool
{ {
(new \Modules\Admin\Jobs\Account\EmailQuality($this->nmo, $this->company))->run();
/* Always send regardless */ /* Always send regardless */
if ($this->override) { if ($this->override) {
return false; return false;

View File

@ -116,6 +116,7 @@ class EmailPayment implements ShouldQueue
$invoice->invitations->each(function ($invite) use ($email_builder) { $invoice->invitations->each(function ($invite) use ($email_builder) {
$cloned_mailable = unserialize(serialize($email_builder)); $cloned_mailable = unserialize(serialize($email_builder));
$nmo = new NinjaMailerObject(); $nmo = new NinjaMailerObject();

View File

@ -134,10 +134,6 @@ class InvoiceEmailEngine extends BaseEmailEngine
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->invoice->numberFormatter().'.pdf']]); $this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->invoice->numberFormatter().'.pdf']]);
} }
// $hash = Str::uuid();
// $url = \Illuminate\Support\Facades\URL::temporarySignedRoute('protected_download', now()->addHour(), ['hash' => $hash]);
// Cache::put($hash, $url, now()->addHour());
//attach third party documents //attach third party documents
if ($this->client->getSetting('document_email_attachment') !== false && $this->invoice->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) { if ($this->client->getSetting('document_email_attachment') !== false && $this->invoice->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
if ($this->invoice->recurring_invoice()->exists()) { if ($this->invoice->recurring_invoice()->exists()) {

View File

@ -99,7 +99,6 @@ class PaymentEmailEngine extends BaseEmailEngine
->setViewLink('') ->setViewLink('')
->setViewText(''); ->setViewText('');
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { if ($this->client->getSetting('pdf_email_attachment') !== false && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$template_in_use = false; $template_in_use = false;

View File

@ -83,9 +83,9 @@ class CompanyPresenter extends EntityPresenter
]; ];
if (strlen($settings->company_logo) >= 1 && (strpos($settings->company_logo, 'http') !== false)) { if (strlen($settings->company_logo) >= 1 && (strpos($settings->company_logo, 'http') !== false)) {
return "data:image/png;base64, ". base64_encode(@file_get_contents($settings->company_logo, false, stream_context_create($context_options))); return "data:image/png;base64,". base64_encode(@file_get_contents($settings->company_logo, false, stream_context_create($context_options)));
} elseif (strlen($settings->company_logo) >= 1) { } elseif (strlen($settings->company_logo) >= 1) {
return "data:image/png;base64, ". base64_encode(@file_get_contents(url('') . $settings->company_logo, false, stream_context_create($context_options))); return "data:image/png;base64,". base64_encode(@file_get_contents(url('') . $settings->company_logo, false, stream_context_create($context_options)));
} else { } else {
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
} }

View File

@ -314,7 +314,7 @@ class Email implements ShouldQueue
$this->logMailError($e->getMessage(), $this->company->clients()->first()); $this->logMailError($e->getMessage(), $this->company->clients()->first());
$this->cleanUpMailers(); $this->cleanUpMailers();
$this->entityEmailFailed($message); $this->entityEmailFailed($message);
return; return;
} }

View File

@ -561,10 +561,19 @@ class HtmlEngine
$data['$spc_qr_code'] = ['value' => $this->company->present()->getSpcQrCode($this->client->currency()->code, $this->entity->number, $this->entity->balance, $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client)), 'label' => '']; $data['$spc_qr_code'] = ['value' => $this->company->present()->getSpcQrCode($this->client->currency()->code, $this->entity->number, $this->entity->balance, $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client)), 'label' => ''];
if(Ninja::isHosted())
$logo = $this->company->present()->logo($this->settings);
else
$logo = $this->company->present()->logo_base64($this->settings); $logo = $this->company->present()->logo_base64($this->settings);
$logo_url = $this->company->present()->logo($this->settings);
$data['$company.logo'] = ['value' => $logo ?: ' ', 'label' => ctrans('texts.logo')]; $data['$company.logo'] = ['value' => $logo ?: ' ', 'label' => ctrans('texts.logo')];
$data['$company_logo'] = &$data['$company.logo']; $data['$company_logo'] = &$data['$company.logo'];
$data['$company.logo_url'] = ['value' => $logo_url ?: ' ', 'label' => ctrans('texts.logo')];
$data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company1')]; $data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company1')];
$data['$company2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company2', $this->settings->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company2')]; $data['$company2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company2', $this->settings->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company2')];
$data['$company3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company3', $this->settings->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company3')]; $data['$company3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company3', $this->settings->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company3')];