Ver código fonte

Merge remote-tracking branch 'origin/master'

= 2 meses atrás
pai
commit
9222514608

+ 6 - 5
app/Http/Controllers/AdminController.php

@@ -568,7 +568,8 @@ class AdminController extends Controller
     $order->save();
 
     if($fileRef === 'results_attachment'){
-        $this->emailReport($request, $order);
+        //$this->emailReport($request, $order);
+        $this->emailService->emailOrderReportReadyAlert($order);
     }
 
     return $this->pass();
@@ -595,20 +596,20 @@ class AdminController extends Controller
   }
 
   public function emailReport(Request $request, StoreOrder $order){
-    //$results_attachment = $order->getDetailJsonValue('results_attachment');
+    $results_attachment = $order->getDetailJsonValue('results_attachment');
 
     $emailParams = [
         'toEmail' => $order->user->getEmail(),
         'toName' => $order->user->displayName(),
         'subject' => 'Your Test Results Are Ready',
-        'message' => $request->get('message')
-        //'attachmentPath' => $results_attachment['path']
+        'message' => $request->get('message'),
+        'attachmentPath' => $results_attachment['path']
     ];
     if(!$emailParams['message']){
         $emailParams['message'] = '<p>Your test results are now available in your secure account.</p><p>To view your results, please click the button below to log in:</p>';
     }
 
-    //$response = $this->emailService->sendEmailWithAttachment($emailParams);
+    $response = $this->emailService->sendEmailWithAttachment($emailParams);
     return $this->pass();
 
   }

+ 28 - 3
app/Http/Services/EmailService.php

@@ -242,7 +242,7 @@ class EmailService
         $html = (string) view('emails.templates.attachment', compact('params', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
         $plainText = (string) '';
 
-       // $attachment = $this->getAttachmentFromStoragePath($params['attachmentPath'], 'attachment1');
+       $attachment = $this->getAttachmentFromStoragePath($params['attachmentPath'], 'attachment1');
 
 
         $emailParams = [
@@ -253,8 +253,8 @@ class EmailService
             'contentHtml' => $html,
             'contentText' => $plainText,
             'entityType' => null,
-            'entityUid' => null
-           // 'attachment1' => $attachment
+            'entityUid' => null,
+           'attachment1' => $attachment
         ];
 
         $response = $this->callJava('/api/email/send', $emailParams, null);
@@ -272,4 +272,29 @@ class EmailService
 
         return null;
     }
+
+    public function emailOrderReportReadyAlert(StoreOrder $storeOrder)
+    {
+        $user = $storeOrder->user;
+        if (!$user->getEmail()) return;
+        $appInternalName = $this->appInternalName;
+        $stringMappingConfig = $this->stringMappingConfig;
+        $appUrl = $this->appUrl;
+        $emailFromName = $this->emailFromName;
+        $html = (string) view('emails.templates.email-order-report-ready-alert', compact('storeOrder', 'user', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
+        $plainText = (string) '';
+
+        $params = [
+            'fromEmailAddress' => $this->fromEmailAddress,
+            'fromName' => $this->emailFromName,
+            'toEmailAddress' => $user->getEmail(),
+            'subject' => 'Lab Results Report Ready',
+            'contentHtml' => $html,
+            'contentText' => $plainText,
+            'entityType' => 'USER',
+            'entityUid' => $user->uid,
+        ];
+
+        $response = $this->callJava('/api/email/send', $params, null);
+    }
 }

+ 14 - 2
resources/views/emails/layout.blade.php

@@ -329,8 +329,20 @@
                                         <tr>
                                             <td class="content-cell" align="center" style="color: #000; 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;">
-                                                    <img src="{{$stringMappingConfig['phoneIcon']}}" style="height:15px;vertical-align: middle;" alt=""><a href="tel:{{ $stringMappingConfig['supportPhone'] }}" style="color:#000;text-decoration: none;font-size:14px;margin-left:7px;">{{ $stringMappingConfig['supportPhone'] }}</a>
-                                                    <img src="{{$stringMappingConfig['emailIcon']}}" style="height:15px;vertical-align: middle;margin-left:50px" alt=""><a href="mailto:{{ $stringMappingConfig['supportEmail'] }}" style="color:#000;text-decoration: none;font-size:14px;margin-left:7px;">{{ $stringMappingConfig['supportEmail'] }}</a></p>
+                                                    @if(@$stringMappingConfig['supportPhone'] && @$stringMappingConfig['phoneIcon'])
+                                                    <img src="{{$stringMappingConfig['phoneIcon']}}" style="height:15px;vertical-align: middle;" alt="">
+                                                    @endif
+                                                    @if(@$stringMappingConfig['supportPhone'])
+                                                    <a href="tel:{{ $stringMappingConfig['supportPhone'] }}" style="color:#000;text-decoration: none;font-size:14px;margin-left:7px;">{{ $stringMappingConfig['supportPhone'] }}</a>
+                                                    @endif
+
+                                                    @if(@$stringMappingConfig['supportEmail'] && @$stringMappingConfig['emailIcon'])
+                                                    <img src="{{$stringMappingConfig['emailIcon']}}" style="height:15px;vertical-align: middle;margin-left:50px" alt="">
+                                                    @endif
+                                                    @if(@$stringMappingConfig['supportEmail'])
+                                                    <a href="mailto:{{ $stringMappingConfig['supportEmail'] }}" style="color:#000;text-decoration: none;font-size:14px;margin-left:7px;">{{ $stringMappingConfig['supportEmail'] }}</a>
+                                                    @endif
+                                                    </p>
                                             </td>
                                         </tr>
                                     </table>

+ 9 - 0
resources/views/emails/templates/email-order-report-ready-alert.blade.php

@@ -0,0 +1,9 @@
+@extends('emails.layout')
+@section('salutation')
+    Hello {{$user->displayName()}},
+@endsection
+
+@section('content')
+<p class="f-fallback" style="color: #000; font-size: 15px; padding: 0 15px; line-height: 24px; margin: .4em 0 1.1875em;">Your lab results report is ready for download. Please click the link below to access lab report results.</p>
+ @include('emails.call-to-action-button', ['link'=>$stringMappingConfig['productUrl'].'/my-account/orders/' . $storeOrder->uid, 'label' => 'View Order Lab Results'])
+@endsection