diff --git a/app/Listeners/Credit/CreditEmailedNotification.php b/app/Listeners/Credit/CreditEmailedNotification.php index 5b6aafe2e6e7..704565e10c8c 100644 --- a/app/Listeners/Credit/CreditEmailedNotification.php +++ b/app/Listeners/Credit/CreditEmailedNotification.php @@ -56,7 +56,7 @@ class CreditEmailedNotification implements ShouldQueue unset($methods[$key]); $nmo = new NinjaMailerObject; - $nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'credit', $event->template))->build()); + $nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'credit', $event->template, $company_user->portalType()))->build()); $nmo->company = $credit->company; $nmo->settings = $credit->company->settings; $nmo->to_user = $user; diff --git a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php index 922d5df2e9c7..8f8fb47887e9 100644 --- a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php +++ b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php @@ -49,7 +49,7 @@ class InvoiceFailedEmailNotification unset($methods[$key]); $nmo = new NinjaMailerObject; - $nmo->mailable = new NinjaMailer((new EntityFailedSendObject($event->invitation->withoutRelations(), 'invoice', $event->template, $event->message))->build()); + $nmo->mailable = new NinjaMailer((new EntityFailedSendObject($event->invitation->withoutRelations(), 'invoice', $event->template, $event->message, $company_user->portalType()))->build()); $nmo->company = $invoice->company->withoutRelations(); $nmo->settings = $invoice->company->settings; $nmo->to_user = $user; diff --git a/app/Listeners/Misc/InvitationViewedListener.php b/app/Listeners/Misc/InvitationViewedListener.php index c27ae85ca103..e57b8402ff19 100644 --- a/app/Listeners/Misc/InvitationViewedListener.php +++ b/app/Listeners/Misc/InvitationViewedListener.php @@ -70,7 +70,7 @@ class InvitationViewedListener implements ShouldQueue $nmo = new NinjaMailerObject; - $nmo->mailable = new NinjaMailer((new EntityViewedObject($invitation, $entity_name))->build()); + $nmo->mailable = new NinjaMailer((new EntityViewedObject($invitation, $entity_name, $company_user->portalType()))->build()); $nmo->company = $invitation->company; $nmo->settings = $invitation->company->settings; diff --git a/app/Listeners/PurchaseOrder/PurchaseOrderAcceptedListener.php b/app/Listeners/PurchaseOrder/PurchaseOrderAcceptedListener.php index e4cd1c170757..0565f914440a 100644 --- a/app/Listeners/PurchaseOrder/PurchaseOrderAcceptedListener.php +++ b/app/Listeners/PurchaseOrder/PurchaseOrderAcceptedListener.php @@ -59,7 +59,7 @@ class PurchaseOrderAcceptedListener implements ShouldQueue unset($methods[$key]); $nmo = new NinjaMailerObject; - $nmo->mailable = new NinjaMailer((new PurchaseOrderAcceptedObject($purchase_order, $event->company))->build()); + $nmo->mailable = new NinjaMailer((new PurchaseOrderAcceptedObject($purchase_order, $event->company, $company_user->portalType()))->build()); $nmo->company = $event->company; $nmo->settings = $event->company->settings; diff --git a/app/Mail/Admin/EntityFailedSendObject.php b/app/Mail/Admin/EntityFailedSendObject.php index e51413e42b79..1120115dd855 100644 --- a/app/Mail/Admin/EntityFailedSendObject.php +++ b/app/Mail/Admin/EntityFailedSendObject.php @@ -39,7 +39,9 @@ class EntityFailedSendObject private $message; - public function __construct($invitation, $entity_type, $template, $message) + protected $use_react_url; + + public function __construct($invitation, $entity_type, $template, $message, $use_react_url) { $this->invitation = $invitation; $this->entity_type = $entity_type; @@ -48,6 +50,7 @@ class EntityFailedSendObject $this->company = $invitation->company; $this->template = $template; $this->message = $message; + $this->use_react_url = $use_react_url; } public function build() @@ -149,7 +152,7 @@ class EntityFailedSendObject 'contact' => $this->contact->present()->name(), ] ), - 'url' => $this->invitation->getAdminLink(), + 'url' => $this->invitation->getAdminLink($this->use_react_url), 'button' => ctrans("texts.view_{$this->entity_type}"), 'signature' => $signature, 'logo' => $this->company->present()->logo(), diff --git a/app/Mail/Admin/EntitySentObject.php b/app/Mail/Admin/EntitySentObject.php index 96c184254f6d..c4337862f64b 100644 --- a/app/Mail/Admin/EntitySentObject.php +++ b/app/Mail/Admin/EntitySentObject.php @@ -36,7 +36,9 @@ class EntitySentObject private $template_body; - public function __construct($invitation, $entity_type, $template) + protected $use_react_url; + + public function __construct($invitation, $entity_type, $template, use_react_url) { $this->invitation = $invitation; $this->entity_type = $entity_type; @@ -44,6 +46,7 @@ class EntitySentObject $this->contact = $invitation->contact; $this->company = $invitation->company; $this->template = $template; + $this->use_react_url = $use_react_url; } public function build() @@ -78,7 +81,7 @@ class EntitySentObject 'purchase_order' => $this->entity->number, ] ), - 'url' => $this->invitation->getAdminLink(), + 'url' => $this->invitation->getAdminLink($this->use_react_url), 'button' => ctrans("texts.view_{$this->entity_type}"), 'signature' => $this->company->settings->email_signature, 'logo' => $this->company->present()->logo(), @@ -185,7 +188,7 @@ class EntitySentObject return [ 'title' => $this->getSubject(), 'message' => $this->getMessage(), - 'url' => $this->invitation->getAdminLink(), + 'url' => $this->invitation->getAdminLink($this->use_react_url), 'button' => ctrans("texts.view_{$this->entity_type}"), 'signature' => $settings->email_signature, 'logo' => $this->company->present()->logo(), diff --git a/app/Mail/Admin/EntityViewedObject.php b/app/Mail/Admin/EntityViewedObject.php index d1a8e171e749..deb52847477c 100644 --- a/app/Mail/Admin/EntityViewedObject.php +++ b/app/Mail/Admin/EntityViewedObject.php @@ -30,13 +30,16 @@ class EntityViewedObject public $settings; - public function __construct($invitation, $entity_type) + protected $use_react_url; + + public function __construct($invitation, $entity_type, $use_react_url) { $this->invitation = $invitation; $this->entity_type = $entity_type; $this->entity = $invitation->{$entity_type}; $this->contact = $invitation->contact; $this->company = $invitation->company; + $this->use_react_url = $use_react_url; } public function build() @@ -104,7 +107,7 @@ class EntityViewedObject 'invoice' => $this->entity->number, ] ), - 'url' => $this->invitation->getAdminLink(), + 'url' => $this->invitation->getAdminLink($this->use_react_url), 'button' => ctrans("texts.view_{$this->entity_type}"), 'signature' => $settings->email_signature, 'logo' => $this->company->present()->logo(), diff --git a/app/Mail/Admin/PurchaseOrderAcceptedObject.php b/app/Mail/Admin/PurchaseOrderAcceptedObject.php index 9d47d728c8b1..8b1372dabc06 100644 --- a/app/Mail/Admin/PurchaseOrderAcceptedObject.php +++ b/app/Mail/Admin/PurchaseOrderAcceptedObject.php @@ -21,16 +21,9 @@ use stdClass; class PurchaseOrderAcceptedObject { - public $purchase_order; - public $company; - - public $settings; - - public function __construct(PurchaseOrder $purchase_order, Company $company) + public function __construct(public PurchaseOrder $purchase_order, public Company $company, protected bool $use_react_url) { - $this->purchase_order = $purchase_order; - $this->company = $company; } public function build() @@ -90,7 +83,7 @@ class PurchaseOrderAcceptedObject 'purchase_order' => $this->purchase_order->number, ] ), - 'url' => $this->purchase_order->invitations->first()->getAdminLink(), + 'url' => $this->purchase_order->invitations->first()->getAdminLink($this->use_react_url), 'button' => ctrans('texts.view_purchase_order'), 'signature' => $settings->email_signature, 'logo' => $this->company->present()->logo(), diff --git a/app/Mail/Admin/QuoteApprovedObject.php b/app/Mail/Admin/QuoteApprovedObject.php index 1311e1a8dcc3..e99530c410f6 100644 --- a/app/Mail/Admin/QuoteApprovedObject.php +++ b/app/Mail/Admin/QuoteApprovedObject.php @@ -21,16 +21,9 @@ use stdClass; class QuoteApprovedObject { - public $quote; - public $company; - - public $settings; - - public function __construct(Quote $quote, Company $company) + public function __construct(public Quote $quote, public Company $company, public bool $use_react_url) { - $this->quote = $quote; - $this->company = $company; } public function build() @@ -90,7 +83,7 @@ class QuoteApprovedObject 'invoice' => $this->quote->number, ] ), - 'url' => $this->quote->invitations->first()->getAdminLink(), + 'url' => $this->quote->invitations->first()->getAdminLink($this->use_react_url), 'button' => ctrans('texts.view_quote'), 'signature' => $settings->email_signature, 'logo' => $this->company->present()->logo(), diff --git a/app/Mail/Admin/QuoteExpiredObject.php b/app/Mail/Admin/QuoteExpiredObject.php index 2da8aeb0856b..f3d63050db94 100644 --- a/app/Mail/Admin/QuoteExpiredObject.php +++ b/app/Mail/Admin/QuoteExpiredObject.php @@ -21,16 +21,9 @@ use stdClass; class QuoteExpiredObject { - public $quote; - public $company; - - public $settings; - - public function __construct(Quote $quote, Company $company) + public function __construct(public Quote $quote, public Company $company, public bool $use_react_url) { - $this->quote = $quote; - $this->company = $company; } public function build() @@ -90,7 +83,7 @@ class QuoteExpiredObject 'invoice' => $this->quote->number, ] ), - 'url' => $this->quote->invitations->first()->getAdminLink(), + 'url' => $this->quote->invitations->first()->getAdminLink($this->use_react_url), 'button' => ctrans('texts.view_quote'), 'signature' => $settings->email_signature, 'logo' => $this->company->present()->logo(),