diff --git a/app/Http/Controllers/ClientPortal/EmailPreferencesController.php b/app/Http/Controllers/ClientPortal/EmailPreferencesController.php new file mode 100644 index 000000000000..247b3bba7446 --- /dev/null +++ b/app/Http/Controllers/ClientPortal/EmailPreferencesController.php @@ -0,0 +1,45 @@ +hasValidSignature()) { + abort(404); + } + + $data['recieve_emails'] = $clientContact->is_locked ? false : true; + $data['logo'] = $clientContact->company->present()->logo(); + + return $this->render('generic.email_preferences', $data); + } + + public function update(ClientContact $clientContact, Request $request): \Illuminate\Http\RedirectResponse + { + if (!$request->hasValidSignature()) { + abort(404); + } + + $clientContact->is_locked = $request->has('recieve_emails') ? false : true; + $clientContact->save(); + + return back()->with('message', ctrans('texts.updated_settings')); + } +} + diff --git a/app/Services/Email/Email.php b/app/Services/Email/Email.php index cfe56bfb2f9e..d529eedf0b5a 100644 --- a/app/Services/Email/Email.php +++ b/app/Services/Email/Email.php @@ -99,6 +99,8 @@ class Email implements ShouldQueue { MultiDB::setDb($this->company->db); + info('here 1'); + $this->setOverride() ->initModels() ->setDefaults() @@ -241,6 +243,8 @@ class Email implements ShouldQueue { $this->mailable = new EmailMailable($this->email_object); + info('here 2'); + return $this; } @@ -264,6 +268,10 @@ class Email implements ShouldQueue $mailer->mailgun_config($this->client_mailgun_secret, $this->client_mailgun_domain, $this->client_mailgun_endpoint); } + info("here 4"); + info($this->mailable->view); + info(print_r($this->mailable)); + /* Attempt the send! */ try { nlog("Using mailer => ". $this->mailer. " ". now()->toDateTimeString()); diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index d4fe57993252..232d66995bf8 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -765,6 +765,8 @@ class HtmlEngine $data[$key] = $value['value']; } + info("here 3"); + return $data; } diff --git a/resources/views/email/template/plain.blade.php b/resources/views/email/template/plain.blade.php index 270144bf7931..7ee4034ea7b4 100644 --- a/resources/views/email/template/plain.blade.php +++ b/resources/views/email/template/plain.blade.php @@ -44,6 +44,11 @@

@endif @endisset + +

Hello world

+

@isset($portal_url) {{ $portal_url }} @endisset

+

After portal

+ @if(isset($unsubscribe_link))

{{ ctrans('texts.unsubscribe') }}

@endif \ No newline at end of file diff --git a/resources/views/portal/ninja2020/generic/email_preferences.blade.php b/resources/views/portal/ninja2020/generic/email_preferences.blade.php new file mode 100644 index 000000000000..2c32ee9db0d5 --- /dev/null +++ b/resources/views/portal/ninja2020/generic/email_preferences.blade.php @@ -0,0 +1,37 @@ +@extends('portal.ninja2020.layout.clean') @section('meta_title', +ctrans('texts.preferences')) @section('body') +
+
+
+ Invoice Ninja logo +

+ {{ ctrans('texts.email_settings') }} +

+ +
+ @csrf @method('put') + + + +
+ +
+
+
+
+
+@stop diff --git a/routes/client.php b/routes/client.php index 870b3514abdb..95956d4e5df4 100644 --- a/routes/client.php +++ b/routes/client.php @@ -1,5 +1,6 @@ middleware('throttle:404'); + + +Route::get('client/email_preferences/{clientContact}', [EmailPreferencesController::class, 'index'])->name('client.email_preferences'); +Route::put('client/email_preferences/{clientContact}', [EmailPreferencesController::class, 'update']);