Samson Mutunga vor 1 Jahr
Ursprung
Commit
5bb73eaeb2

+ 75 - 0
app/Http/Controllers/EmailController.php

@@ -0,0 +1,75 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\File;
+
+use App\Http\Services\EmailService;
+use App\Models\Account;
+use App\Models\AppSession;
+use App\Models\Invoice;
+use App\Models\FinancialTransaction;
+use App\Models\CompanyClient;
+use Illuminate\Support\Facades\Cookie;
+
+
+class EmailController extends Controller
+{
+    protected $performer;
+    protected $sessionKey;
+
+    public $appUrl;
+    protected $emailService;
+    public $appInternalName;
+    public $stringMappingConfig;
+    protected $emailFromName;
+
+    public function __construct(EmailService $emailService)
+    {
+        $this->sessionKey = Cookie::get('sessionKey');
+        $this->performer = AppSession::where('session_key', $this->sessionKey)->first();
+
+        $this->emailFromName = config('app.emailFromName');
+        $this->appUrl = config('app.url');
+        $this->emailService = $emailService;
+        $this->appInternalName = config('app.internalName');
+        $this->stringMappingConfig = config('constants.' . $this->appInternalName);
+    }
+
+    public function previewEmail($email = null)
+    {
+        $pro = @$this->performer->pro;
+        if (!$pro) {
+            abort(404);
+        }
+        $appInternalName = $this->appInternalName;
+        $stringMappingConfig = $this->stringMappingConfig;
+
+        if ($email) {
+            $destinationPath = resource_path('views/emails/templates/' . $email . '.blade.php');
+            if (File::exists($destinationPath)) {
+                $content = File::get($destinationPath);
+                $appUrl = $this->appUrl;
+                $emailFromName = $this->emailFromName;   
+                $toEmailAddress = $this->pro ? $this->pro->email_address : 'john@doe.com';             
+                $toName = $this->pro ? $this->pro->displayName() : 'John Doe';
+                $message = 'Client information has been updated';
+                return view('emails/templates/' . $email, compact('appUrl', 'toEmailAddress', 'toName', 'message', 'stringMappingConfig', 'appInternalName', 'emailFromName'));
+            } else {
+                abort(404);
+            }
+        }
+        $files = File::allFiles(resource_path('views/emails/templates/'));
+
+        $fileNames = [];
+        foreach ($files as $file) {
+            $fileName = $file->getFilename();
+            $fileNameParts = explode('.', $fileName);
+            $fileRef = @$fileNameParts[0];
+            if ($fileRef) array_push($fileNames, $fileRef);
+        }
+
+        return view('emails.preview-email', compact('fileNames'));
+    }
+}

+ 1 - 0
config/app.php

@@ -91,6 +91,7 @@ return [
     'defaultErxCompanyCity' => env('DEFAULT_ERX_COMPANY_CITY'),
     'defaultErxCompanyState' => env('DEFAULT_ERX_COMPANY_STATE'),
     'defaultErxCompanyZip' => env('DEFAULT_ERX_COMPANY_ZIP'),
+    'internalName' => env('APP_INTERNAL_NAME', 'lh'),
 
     /*
     |--------------------------------------------------------------------------

+ 0 - 0
public/app/lh/logo-white.png → public/app/lh/img/logo-white.png


+ 0 - 0
public/app/lh/logo.png → public/app/lh/img/logo.png


+ 4 - 4
resources/views/emails/layout.blade.php

@@ -296,7 +296,7 @@
             <table class="email-content" width="650" cellpadding="0" cellspacing="0" role="presentation" style="margin: 0; padding: 0;" border="0">
                 <tr>
                     <td class="email-masthead" style="background-color:#ffffff;color: #625F5F; font-family:Arial, sans-serif; font-size: 16px; padding: 15px; text-align: center; word-break: break-word;">
-                        <img src="{{ config('app.url') }}/app/{{ $appInternalName }}/img/logo.png" alt=""  height="100"  style="border: none;max-width:400px;object-fit:contain;">
+                        <img src="{{ $stringMappingConfig['logo'] }}" alt=""  height="100"  style="border: none;max-width:400px;object-fit:contain;">
                     </td>
                 </tr>
                 <!-- Email Body -->
@@ -328,11 +328,11 @@
                                         <tr>
                                             <td class="content-cell" align="center" style="color: #625F5F; font-family:Arial, sans-serif; font-size: 16px; padding: 0;word-break: break-word;">
                                                 <p style="text-align:center;padding:15px 0 15px; margin:0;">
-                                                    <a target="_blank" href="{{ route('index') }}">Support</a>
+                                                    <a target="_blank" href="{{ config('app.stagfe6_url') }}">Support</a>
                                                     <span style="margin:0 10px;color:#cccccc;">|</span>
-                                                    <a target="_blank" href="{{ route('privacy-policy') }}">Privacy Policy</a>
+                                                    <a target="_blank" href="{{ config('app.stagfe6_url') . '/privacy-policy' }}">Privacy Policy</a>
                                                     <span style="margin:0 10px;color:#cccccc;">|</span>
-                                                    <a target="_blank" href="{{ route('unsubscribe', @$account->uid?? @$toEmailAddress) }}">Unsubscribe</a>
+                                                    <a target="_blank" href="{{ config('app.stagfe6_url') .'/emails/unsubscribe/' . @$toEmailAddress }}">Unsubscribe</a>
             
                                                 </p>
                                                 <p style="text-align: center;margin:0 0 15px 0;">Copyright © {{ date('Y') }} {{ config('app.name') }}. All Rights Reserved.</p>

+ 0 - 14
resources/views/emails/templates/account-client-payment-method-added-email.blade.php

@@ -1,14 +0,0 @@
-@extends('emails.layout')
-<?php
-  $appInternalName = config('app.internalName');
-  $appConfig = config('constants.' . $appInternalName);
- ?>
-@section('salutation')
-    Dear {{$client->displayName()}}!
-@endsection
-
-@section('content')
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">We wanted to inform you that a new payment method has been successfully added to your Sleep Care America account. This secure payment information will streamline your experience, ensuring smooth and hassle-free transactions for your services.</p>
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">Should you have any concerns about this update or require further assistance, please do not hesitate to reach out to our support team at <b>{{ config('app.phone') }}</b>.</p>
-
-@endsection

+ 0 - 16
resources/views/emails/templates/account-confirm-email.blade.php

@@ -1,16 +0,0 @@
-@extends('emails.layout')
-<?php
-  $appInternalName = config('app.internalName');
-  $appConfig = config('constants.' . $appInternalName);
- ?>
-@section('salutation')
-    Welcome, {{$account->displayName()}}!
-@endsection
-
-@section('content')
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">Thank you for signing up. We’re thrilled to have you onboard. Please click the link below to complete the process.</p>
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">Confirmation Code: <b style="color:{{$appConfig['primaryColor']}}">{{$account->email_confirmation_token}}</b></p>
-
-    @include('emails.call-to-action-button', ['link'=> route('confirm-account-email', $account->email_confirmation_token), 'label' => 'Activate your account'])
-
-@endsection

+ 0 - 10
resources/views/emails/templates/account-notify-on-password-change-email.blade.php

@@ -1,10 +0,0 @@
-@extends('emails.layout')
-@section('salutation')
-    Hi, {{$account->displayName()}}!
-@endsection
-
-@section('content')
-    <p class="f-fallback" style="color: #625F5F; font-size: 17px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">This is to confirm that your password for Sleep Care America has been successfully updated. Your account security is our priority, and we want to ensure that your information remains protected.</p>
-    <p class="f-fallback" style="color: #625F5F; font-size: 17px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">If you did not initiate this change or have any concerns about the security of your account, please contact our support team immediately at <b>{{ config('app.phone') }}</b>.</p>
-
-@endsection

+ 0 - 18
resources/views/emails/templates/account-password-reset-email.blade.php

@@ -1,18 +0,0 @@
-@extends('emails.layout')
-<?php
-  $appInternalName = config('app.internalName');
-  $appConfig = config('constants.' . $appInternalName);
- ?>
-@section('salutation')
-    Dear, {{$account->displayName()}}
-@endsection
-
-@section('content')
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">We've received your request to reset your password for your Sleep Care America account. Your account security is important to us, and we're here to assist you.</p>
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">To reset your password, please click the link below:</p>
-
-
-    @include('emails.call-to-action-button', ['link'=> route('reset-password', $account->password_reset_token), 'label' => 'Reset Password'])
-
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">If you did not make this request or need further assistance, please contact our support team immediately by replying to this email or calling <a href="tel:{{ $stringMappingConfig['supportPhone'] }}" style="color:#000;text-decoration: none;font-size:16px;margin-left:7px;">{{ $stringMappingConfig['supportPhone'] }}</a>.</p>
-@endsection

+ 0 - 16
resources/views/emails/templates/account-request-change-email-email.blade.php

@@ -1,16 +0,0 @@
-@extends('emails.layout')
-<?php
-  $appInternalName = config('app.internalName');
-  $appConfig = config('constants.' . $appInternalName);
- ?>
-@section('salutation')
-    Hi, {{$account->displayName()}}!
-@endsection
-
-@section('content')
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">You have requested to change your account email address.</p>
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">Verification Code: <b style="color:{{$appConfig['primaryColor']}}">{{$account->switch_email_confirmation_token}}</b></p>
-
-    @include('emails.call-to-action-button', ['link'=> route('settings.email-settings', $account->switch_email_confirmation_token), 'label' => 'Confirm Change Email Address'])
-
-@endsection

+ 0 - 18
resources/views/emails/templates/account-temporary-password-email.blade.php

@@ -1,18 +0,0 @@
-@extends('emails.layout')
-<?php
-  $appInternalName = config('app.internalName');
-  $appConfig = config('constants.' . $appInternalName);
- ?>
-@section('salutation')
-    Welcome, {{$account->displayName()}}!
-@endsection
-
-@section('content')
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">Thank you for signing up. We’re thrilled to have you onboard. Below is your temporary password to access your account.</p>
-    <p class="f-fallback" style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">Temporary Password: <b style="color:{{$appConfig['primaryColor']}}">{{$temporaryPassword}}</b></p>
-
-    @include('emails.call-to-action-button', ['link'=> route('my-account.dashboard'), 'label' => 'Access your account'])
-
-    <p style="color: #625F5F; font-size: 16px; padding: 0 15px; line-height: 24px; margin: 24px 0 0.1875em;">Please sign in to your account as soon as possible and change your password. Remember, never share your Sleep Care America password with anyone, including Sleep Care America support staff.</p>
-
-@endsection

+ 19 - 0
resources/views/emails/templates/error-email.blade.php

@@ -0,0 +1,19 @@
+@extends('emails.layout')
+<?php
+$appInternalName = config('app.internalName');
+$appConfig = config('constants.' . $appInternalName);
+?>
+@section('salutation')
+    Hi, Admin!
+@endsection
+
+@section('content')
+    <p class="f-fallback" style="color: #000; font-size: 16px; padding: 0 15px; line-height: 30px; margin: .4em 0 0.1875em;">
+        There is new error by code: <b>{{ @$code ?? '---' }}</b><br />
+        Url: <b>{{ request()->url() }}</b><br />
+            Session Key: <b>{{ get_current_session()->session_key }}</b><br>
+        @if(get_current_session() && get_current_session()->pro)
+            Pro: <b>{{ get_current_session()->pro->displayName() }}</b><br>
+        @endif
+        </p>
+@endsection

+ 0 - 14
resources/views/emails/templates/notify-on-client-change-email.blade.php

@@ -1,14 +0,0 @@
-@extends('emails.layout')
-<?php
-$appInternalName = config('app.internalName');
-$appConfig = config('constants.' . $appInternalName);
-?>
-@section('salutation')
-    Hi, {{ $toName }}!
-@endsection
-
-@section('content')
-    <div class="f-fallback" style="color: #625F5F; background-color: #FFFFFF; padding: 0 15px; font-size: 16px; line-height: 24px; margin: 0;">
-        <p style="margin:0;"><?= $message ?></p>
-    </div>
-@endsection

+ 4 - 0
routes/web.php

@@ -10,6 +10,7 @@ use App\Http\Controllers\CompanyClientController;
 use App\Http\Controllers\CustomerController;
 use App\Http\Controllers\ClientProAccessController;
 use App\Http\Controllers\RdController;
+use App\Http\Controllers\EmailController;
 
 /*
 |--------------------------------------------------------------------------
@@ -878,3 +879,6 @@ Route::post('/start/{sessionId}', [VideoTestController::class, 'startRecording']
 Route::post('/stop/{archiveId}', [VideoTestController::class, 'stopRecording'])->name('stop_recording');
 Route::post('/save-archive', [VideoTestController::class, 'saveArchive'])->name('save_archive');
 Route::post('/upload-video', [VideoTestController::class, 'uploadVideo'])->name('upload_video');
+
+//Emails
+Route::get('/emails/preview/{email?}', [EmailController::class, 'previewEmail'])->name('preview-email');