mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 15:04:37 -04:00
Improve template switching for hosted users
This commit is contained in:
parent
c5b6938447
commit
83215cd0bc
@ -67,7 +67,7 @@ class TokenAuth
|
|||||||
$truth->setUser($company_token->user);
|
$truth->setUser($company_token->user);
|
||||||
$truth->setCompany($company_token->company);
|
$truth->setCompany($company_token->company);
|
||||||
$truth->setCompanyToken($company_token);
|
$truth->setCompanyToken($company_token);
|
||||||
|
$truth->setPremiumHosted($company_token->account->isPremium());
|
||||||
/*
|
/*
|
||||||
| This method binds the db to the jobs created using this
|
| This method binds the db to the jobs created using this
|
||||||
| session
|
| session
|
||||||
|
@ -94,6 +94,7 @@ class UserEmailChanged implements ShouldQueue
|
|||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
'settings' => $this->settings,
|
'settings' => $this->settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ class ClientUnsubscribedObject
|
|||||||
'settings' => $this->company->settings,
|
'settings' => $this->company->settings,
|
||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
'text_body' => "\n\n".ctrans('texts.client_unsubscribed_help', ['client' => $this->contact->present()->name()])."\n\n",
|
'text_body' => "\n\n".ctrans('texts.client_unsubscribed_help', ['client' => $this->contact->present()->name()])."\n\n",
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
$mail_obj = new \stdClass();
|
$mail_obj = new \stdClass();
|
||||||
|
@ -94,7 +94,8 @@ class EntityCreatedObject
|
|||||||
'settings' => $this->company->settings,
|
'settings' => $this->company->settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
'text_body' => str_replace(['$view_button','$viewButton','$viewLink','$view_url'], '$view_url', $content),
|
'text_body' => str_replace(['$view_button','$viewButton','$viewLink','$view_url'], '$view_url', $content),
|
||||||
];
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
$this->entity->load('client.country', 'client.company');
|
$this->entity->load('client.country', 'client.company');
|
||||||
$this->client = $this->entity->client;
|
$this->client = $this->entity->client;
|
||||||
@ -181,6 +182,7 @@ class EntityCreatedObject
|
|||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
'text_body' => str_replace(['$view_button','$viewButton','$view_link','$view_button'], '$view_url', $content),
|
'text_body' => str_replace(['$view_button','$viewButton','$view_link','$view_button'], '$view_url', $content),
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,7 @@ class EntityFailedSendObject
|
|||||||
"settings" => $settings,
|
"settings" => $settings,
|
||||||
"whitelabel" => $this->company->account->isPaid() ? true : false,
|
"whitelabel" => $this->company->account->isPaid() ? true : false,
|
||||||
"text_body" => str_replace("<br>", "\n", $content),
|
"text_body" => str_replace("<br>", "\n", $content),
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -105,6 +105,7 @@ class EntityPaidObject
|
|||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
'text_body' => $content,
|
'text_body' => $content,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -87,6 +87,8 @@ class EntitySentObject
|
|||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
'settings' => $this->company->settings,
|
'settings' => $this->company->settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
|
|
||||||
];
|
];
|
||||||
$mail_obj->markdown = 'email.admin.generic';
|
$mail_obj->markdown = 'email.admin.generic';
|
||||||
$mail_obj->tag = $this->company->company_key;
|
$mail_obj->tag = $this->company->company_key;
|
||||||
@ -197,6 +199,8 @@ class EntitySentObject
|
|||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
'text_body' => $content,
|
'text_body' => $content,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,7 @@ class EntityViewedObject
|
|||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
'text_body' => $content,
|
'text_body' => $content,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -76,6 +76,7 @@ class InventoryNotificationObject
|
|||||||
'settings' => $this->product->company->settings,
|
'settings' => $this->product->company->settings,
|
||||||
'whitelabel' => $this->product->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->product->company->account->isPaid() ? true : false,
|
||||||
'text_body' => $content,
|
'text_body' => $content,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -99,6 +99,7 @@ class PaymentFailureObject
|
|||||||
'button' => $this->use_react_url ? ctrans('texts.view_client') : ctrans('texts.login'),
|
'button' => $this->use_react_url ? ctrans('texts.view_client') : ctrans('texts.login'),
|
||||||
'additional_info' => $this->error,
|
'additional_info' => $this->error,
|
||||||
'text_body' => $content,
|
'text_body' => $content,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -92,6 +92,7 @@ class PurchaseOrderAcceptedObject
|
|||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
'text_body' => $content,
|
'text_body' => $content,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -91,6 +91,7 @@ class QuoteApprovedObject
|
|||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
'text_body' => $content,
|
'text_body' => $content,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -91,6 +91,8 @@ class QuoteExpiredObject
|
|||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||||
'text_body' => $content,
|
'text_body' => $content,
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -41,6 +41,7 @@ class ResetPasswordObject
|
|||||||
'settings' => $this->company->settings,
|
'settings' => $this->company->settings,
|
||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
'text_body' => ctrans('texts.reset_password'),
|
'text_body' => ctrans('texts.reset_password'),
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
$mail_obj = new \stdClass();
|
$mail_obj = new \stdClass();
|
||||||
|
@ -53,6 +53,7 @@ class VerifyUserObject
|
|||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
'signature' => $this->company->settings->email_signature,
|
'signature' => $this->company->settings->email_signature,
|
||||||
'text_body' => ctrans('texts.confirmation_message'),
|
'text_body' => ctrans('texts.confirmation_message'),
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
$mail_obj = new \stdClass();
|
$mail_obj = new \stdClass();
|
||||||
|
@ -52,7 +52,7 @@ class ClientStatement extends Mailable
|
|||||||
public function content()
|
public function content()
|
||||||
{
|
{
|
||||||
return new Content(
|
return new Content(
|
||||||
view: 'email.template.client',
|
view: $this->data['company']->account->isPremium() ? 'email.template.client_premium' : 'email.template.client',
|
||||||
text: 'email.template.text',
|
text: 'email.template.text',
|
||||||
with: [
|
with: [
|
||||||
'text_body' => $this->data['body'],
|
'text_body' => $this->data['body'],
|
||||||
|
@ -48,6 +48,7 @@ class ClientContactRequestCancellationObject
|
|||||||
'signature' => $this->company->settings->email_signature,
|
'signature' => $this->company->settings->email_signature,
|
||||||
'settings' => $this->company->settings,
|
'settings' => $this->company->settings,
|
||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
];
|
];
|
||||||
|
|
||||||
$mail_obj = new \stdClass();
|
$mail_obj = new \stdClass();
|
||||||
|
@ -58,6 +58,7 @@ class OtpCode extends Mailable
|
|||||||
'title' => ctrans('texts.otp_code_subject'),
|
'title' => ctrans('texts.otp_code_subject'),
|
||||||
'content' => ctrans('texts.otp_code_body', ['code' => $this->code]),
|
'content' => ctrans('texts.otp_code_body', ['code' => $this->code]),
|
||||||
'whitelabel' => $this->company->account->isPaid(),
|
'whitelabel' => $this->company->account->isPaid(),
|
||||||
|
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ class TemplateEmail extends Mailable
|
|||||||
$template_name = 'email.template.'.$this->build_email->getTemplate();
|
$template_name = 'email.template.'.$this->build_email->getTemplate();
|
||||||
|
|
||||||
if ($this->build_email->getTemplate() == 'light' || $this->build_email->getTemplate() == 'dark') {
|
if ($this->build_email->getTemplate() == 'light' || $this->build_email->getTemplate() == 'dark') {
|
||||||
$template_name = 'email.template.client';
|
$template_name = $this->company->account->isPremium() ? 'email.template.client_premium' : 'email.template.client';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->build_email->getTemplate() == 'custom') {
|
if ($this->build_email->getTemplate() == 'custom') {
|
||||||
|
@ -72,7 +72,7 @@ class VendorTemplateEmail extends Mailable
|
|||||||
$template_name = 'email.template.'.$this->build_email->getTemplate();
|
$template_name = 'email.template.'.$this->build_email->getTemplate();
|
||||||
|
|
||||||
if ($this->build_email->getTemplate() == 'light' || $this->build_email->getTemplate() == 'dark') {
|
if ($this->build_email->getTemplate() == 'light' || $this->build_email->getTemplate() == 'dark') {
|
||||||
$template_name = 'email.template.client';
|
$template_name = $this->company->account->isPremium() ? 'email.template.client_premium' : 'email.template.client';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->build_email->getTemplate() == 'custom') {
|
if ($this->build_email->getTemplate() == 'custom') {
|
||||||
|
@ -24,18 +24,6 @@ class ComposerServiceProvider extends ServiceProvider
|
|||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
view()->composer('portal.*', PortalComposer::class);
|
view()->composer('portal.*', PortalComposer::class);
|
||||||
|
|
||||||
// view()->composer(
|
|
||||||
// ['email.admin.generic', 'email.client.generic'],
|
|
||||||
// function ($view) {
|
|
||||||
// $view->with(
|
|
||||||
// 'template',
|
|
||||||
// Ninja::isHosted()
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,6 +68,7 @@ class AdminEmailMailable extends Mailable
|
|||||||
'logo' => $this->email_object->company->present()->logo(),
|
'logo' => $this->email_object->company->present()->logo(),
|
||||||
'settings' => $this->email_object->settings,
|
'settings' => $this->email_object->settings,
|
||||||
'whitelabel' => $this->email_object->company->account->isPaid() ? true : false,
|
'whitelabel' => $this->email_object->company->account->isPaid() ? true : false,
|
||||||
|
'template' => $this->email_object->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -107,10 +107,10 @@ class EmailDefaults
|
|||||||
|
|
||||||
match ($this->email->email_object->settings->email_style) {
|
match ($this->email->email_object->settings->email_style) {
|
||||||
'plain' => $this->template = 'email.template.plain',
|
'plain' => $this->template = 'email.template.plain',
|
||||||
'light' => $this->template = 'email.template.client',
|
'light' => $this->template = $this->email->email_object->company->account->isPremium() ? 'email.template.client_premium' : 'email.template.client',
|
||||||
'dark' => $this->template = 'email.template.client',
|
'dark' => $this->template = $this->email->email_object->company->account->isPremium() ? 'email.template.client_premium' :'email.template.client',
|
||||||
'custom' => $this->template = 'email.template.custom',
|
'custom' => $this->template = 'email.template.custom',
|
||||||
default => $this->template = 'email.template.client',
|
default => $this->template = $this->email->email_object->company->account->isPremium() ? 'email.template.client_premium' :'email.template.client',
|
||||||
};
|
};
|
||||||
|
|
||||||
$this->email->email_object->html_template = $this->template;
|
$this->email->email_object->html_template = $this->template;
|
||||||
|
@ -21,6 +21,15 @@ class TruthSource
|
|||||||
|
|
||||||
public $company_token;
|
public $company_token;
|
||||||
|
|
||||||
|
public $premium_hosted;
|
||||||
|
|
||||||
|
public function setPremiumHosted($premium_hosted)
|
||||||
|
{
|
||||||
|
$this->premium_hosted = $premium_hosted;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setCompanyUser($company_user)
|
public function setCompanyUser($company_user)
|
||||||
{
|
{
|
||||||
$this->company_user = $company_user;
|
$this->company_user = $company_user;
|
||||||
@ -49,6 +58,11 @@ class TruthSource
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPremiumHosted()
|
||||||
|
{
|
||||||
|
return $this->premium_hosted;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCompany()
|
public function getCompany()
|
||||||
{
|
{
|
||||||
return $this->company;
|
return $this->company;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
$email_alignment = isset($settings->email_alignment) ? $settings->email_alignment : 'center';
|
$email_alignment = isset($settings->email_alignment) ? $settings->email_alignment : 'center';
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html
|
<!DOCTYPE html
|
||||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* @license https://www.elastic.co/licensing/elastic-license
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature\PaymentLink;
|
||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user