diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 601c3d8..896ca58 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -521,3 +521,10 @@ $routes->post("getPreEmployeePolicyCount", "EmployeeRestController::getPreEmploy +// notification mail template +$routes->get('notification_mail_header',"NotificationController::notification_mail_header"); + +$routes->get('notification_mail_footer',"NotificationController::notification_mail_footer"); + + + diff --git a/app/Controllers/NotificationController.php b/app/Controllers/NotificationController.php index a3d6679..0c3890f 100755 --- a/app/Controllers/NotificationController.php +++ b/app/Controllers/NotificationController.php @@ -280,4 +280,31 @@ class NotificationController extends AdminController } } + // This function for load the mail header in notification mail template + public function notification_mail_header(){ + + $params = []; + $params['client_data'] = $this->clientModel->where('id', 12)->first(); + + return view('notification_mail_header',$params); + } + + + public function notification_mail_footer(){ + + $params = []; + $params['client_data'] = $this->clientModel->where('id', 12)->first(); + + return view('notification_mail_footer',$params); + } + + + + + + + + + + } \ No newline at end of file diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 10b38a3..01ff5d5 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -13,11 +13,12 @@ use App\Models\PolicyPremium2Model; use App\Models\MailAttachmentModel; use Kint\Kint; +// send mail notification class sendMailNotification { public static function sendMailNotification($action, $params) { - $wholeData =[]; + $wholeData = []; if ($action == 'member_welcome_mail') { @@ -28,11 +29,11 @@ class sendMailNotification $mailAttachmentModel = new MailAttachmentModel(); $attachment_data = $mailAttachmentModel - ->select('file_path, file_name') - ->where('notification_id', $notification['id']) - ->where('is_active', 1) - ->findAll(); - + ->select('file_path, file_name') + ->where('notification_id', $notification['id']) + ->where('is_active', 1) + ->findAll(); + $attachments = []; foreach ($attachment_data as $data) { $attachments[] = [ @@ -42,10 +43,10 @@ class sendMailNotification } $mail = $dataToInsert['email_corporate']; - $subject = $notification['subject']; + $subject = $notification['subject']; $app_link = $_ENV['App_Url']; - $employee_name =$dataToInsert['name']; - $employee_mobile_no =$dataToInsert['mobile']; + $employee_name = $dataToInsert['name']; + $employee_mobile_no = $dataToInsert['mobile']; $mail_content = $notification['mail_content']; $nhance_logo = $_ENV['NHANCE_LOGO']; $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; @@ -58,12 +59,21 @@ class sendMailNotification $mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "Review Details", $mail_content); if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') { - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments, 'common' => $common]; - } - - return $wholeData; + + - } else if($action == 'member_reminder_mail'){ + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments, 'common' => $common]; + } + + return $wholeData; + } else if ($action == 'member_reminder_mail') { $EmployeeModel = new EmployeeModel(); $emp_data = $params['emp_data']; @@ -71,31 +81,38 @@ class sendMailNotification $client_data = $params['client_data']; $common = $params['common']; - $subject = $notification_data['subject']; + $subject = $notification_data['subject']; $app_link = $_ENV['App_Url']; $mail_content = $notification_data['mail_content']; $nhance_logo = $_ENV['NHANCE_LOGO']; $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; - + $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); $mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "Nhance Logo", $mail_content); $mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "Client Logo", $mail_content); $mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "Review Details", $mail_content); - - $employee_name =$emp_data['name']; - $employee_mobile_no =$emp_data['mobile']; + + $employee_name = $emp_data['name']; + $employee_mobile_no = $emp_data['mobile']; $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $employee_name, $mail_content); $mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $employee_mobile_no, $mail_content); - $mail = $emp_data['email_corporate']; + $mail = $emp_data['email_corporate']; - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; + + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; return $wholeData; - - - } else if($action == 'member_ecard_mail'){ + } else if ($action == 'member_ecard_mail') { $notification = $params['notification']; $get_emp_email_and_other_details = $params['get_emp_email_and_other_details']; @@ -113,8 +130,8 @@ class sendMailNotification $cleanedText = preg_replace('/[^\x20-\x7E]/', '', $cleanedText); $subject = $cleanedText; - - $link = generate_download_link($rand_string).'/1'; + + $link = generate_download_link($rand_string) . '/1'; $app_link = $_ENV['App_Url']; $name = $get_emp_email_and_other_details['name']; @@ -125,10 +142,10 @@ class sendMailNotification // dd("3333333333333"); $post_enrollment_app_link = $_ENV['POST_ENROLLMENT_APP_LINK']; - + $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; // $client_logo = $nhance_logo; - + $mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "Nhance Logo", $mail_content); $mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "Client Logo", $mail_content); @@ -139,14 +156,22 @@ class sendMailNotification // $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content); $mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "Download Insurance Card", $mail_content); $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); - - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; + + + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; return $wholeData; + } else if ($action == 'member_review_and_summary_mail') { - } else if($action == 'member_review_and_summary_mail'){ - - $array_list = $params['array_list'];//employeee lst + $array_list = $params['array_list']; //employeee lst $client_policy_id = $params['client_policy_id']; $emp_code = $params['emp_code']; $client_id = $params['client_id']; @@ -159,9 +184,10 @@ class sendMailNotification $PolicyPremium2Model = new PolicyPremium2Model(); - $client_data =$clientModel->where('id', $client_id)->first(); - $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); + $client_data = $clientModel->where('id', $client_id)->first(); + $notification_data = $notificationModel->where('client_id', $client_id)->where('template_name', $action)->first(); + $params['client_data'] = $client_data; // dd($notification_data); if (isset($notification_data) && $notification_data['enabled'] == 1) { @@ -170,7 +196,7 @@ class sendMailNotification $subject = $notification_data['subject']; $app_link = $_ENV['App_Url']; $nhance_logo = $_ENV['NHANCE_LOGO']; - + $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; // $client_logo = $nhance_logo; @@ -193,12 +219,12 @@ class sendMailNotification // echo '
';
                 // dd($array_list); die;
 
-               
+
 
                 foreach ($array_list as $item) {
 
                     $payable_employee_array = [];
-                    
+
                     if (count($item) != 0) {
 
                         $table_content .= '

Policy Type :'; @@ -207,71 +233,70 @@ class sendMailNotification $is_addon = ''; $rowspan = count($item) ?? 2; $is_si_set = 0; - + foreach ($item as $inner_item) { //getting policy premium data $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first(); - if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){ + if ($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7) { $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); - }else{ + } else { $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); } //end of getting policy premium data // dd($policy_premium_data); - if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){ + if ($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2) { $payable_employee_array['emp_data'][] = $inner_item; } // dd($policy_premium_data); $policy_name = $inner_item['policy_name']; - + if ($inner_item['relationship'] == 'Self') { $emp_code = '(' . $inner_item['emp_code'] . ')'; $mail = $inner_item['email_corporate']; $name = $inner_item['name']; $employee_mobile_no = $inner_item['mobile']; - } + } $si = ''; $premium = ''; $gst_forself = ''; - - if($policy_premium_data['premium_type'] == 2){ - $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); - }else{ + + if ($policy_premium_data['premium_type'] == 2) { + $si = '₹ ' . format_indian_number($inner_item['basic_cover_si']); + } else { if ($inner_item['relationship'] == 'Self') { $payable_employee_array['si_amount'] = $inner_item['basic_cover_si']; $payable_employee_array['self_premium'] = $inner_item['rata_premimum']; $payable_employee_array['self_gst'] = $inner_item['gst']; } - empty($inner_item['basic_cover_si']) ? $si = 0 : $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); + empty($inner_item['basic_cover_si']) ? $si = 0 : $si = '₹ ' . format_indian_number($inner_item['basic_cover_si']); } // Premium summery for show and hide the Additional premium data - if($client_policy_data['is_premium_summery'] == 1){ - $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); - $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); + if ($client_policy_data['is_premium_summery'] == 1) { + $premium = '₹ ' . format_indian_number(round($inner_item['rata_premimum'])); + $gst_forself = '₹ ' . format_indian_number(round($inner_item['gst'])); } - + $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; $temp_data .= '' . $inner_item['relationship'] . ''; $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; - - if($policy_premium_data['premium_type'] == 2){ + + if ($policy_premium_data['premium_type'] == 2) { $temp_data .= '' . $si . ''; - }else{ + } else { // $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . '') : ($si == 0 ? "" : '' . $si . '') ); - + if ($si != 0 && count($item) != 1 && $is_si_set == 0) { - + $temp_data .= '' . $si . ''; $is_si_set = 1; - } else { if ($is_si_set == 1) { @@ -279,21 +304,19 @@ class sendMailNotification } else { $temp_data .= '' . $si . ''; } - } - - + } } - + // Only Display SI Topup and Dependent Addon if (($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) && $client_policy_data['is_premium_summery'] == 1) { $temp_data .= '' . $premium . ''; $temp_data .= '' . $gst_forself . ''; } - + $temp_data .= ''; - + $is_addon = $inner_item['is_addon']; - + if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium; $gst = $inner_item['gst'] + $gst; @@ -301,13 +324,13 @@ class sendMailNotification } $policy_name_for_policy_type = $inner_item['policy_name']; - if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){ + if ($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3) { $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents'; } - + $table_content .= $policy_name_for_policy_type . '

'; $table_content .= ''; - + // Add text-align: center to the table head $table_content .= ''; $table_content .= ''; @@ -315,20 +338,20 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + // Only Display SI Topup and Dependent Addon if (($is_addon == 2 || $is_addon == 3) && $client_policy_data['is_premium_summery'] == 1) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; - + // Add text-align: center to the table body $table_content .= '' . $temp_data . ''; $table_content .= '
RelationDate Of BirthSum InsuredPremiumGST
'; - + if (($is_addon == 2 || $is_addon == 3) && $client_policy_data['is_premium_summery'] == 1) { $addon_list_array = [ 'policy_name' => $policy_name_for_policy_type, @@ -337,7 +360,7 @@ class sendMailNotification ]; $Addon_list[] = $addon_list_array; } - + $temp_data = ''; $addtional_premium = 0; $gst = 0; @@ -346,7 +369,7 @@ class sendMailNotification // Kint::dump($payable_employee_array); // dd(count($payable_employee_array['emp_data'])); - if(isset($payable_employee_array['emp_data']) && count($payable_employee_array['emp_data']) > 0){ + if (isset($payable_employee_array['emp_data']) && count($payable_employee_array['emp_data']) > 0) { $table_content .= '

Policy Type :'; $temp_data = ''; @@ -359,14 +382,14 @@ class sendMailNotification // dd($payable_employee_array['si_amount'], $self_si_amount); - + foreach ($payable_employee_array['emp_data'] as $inner_item) { //getting policy premium data $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first(); - if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){ + if ($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7) { $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); - }else{ + } else { $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); } //end of getting policy premium data @@ -376,80 +399,76 @@ class sendMailNotification $si = ''; $premium = ''; $gst_forself = ''; - - if($policy_premium_data['premium_type'] == 2){ - $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); - }else{ - empty($self_si_amount) ? $si = 0 : $si = '₹ ' .format_indian_number($self_si_amount); + + if ($policy_premium_data['premium_type'] == 2) { + $si = '₹ ' . format_indian_number($inner_item['basic_cover_si']); + } else { + empty($self_si_amount) ? $si = 0 : $si = '₹ ' . format_indian_number($self_si_amount); } - if($policy_premium_data['premium_type'] == 1){ - - empty($self_premium) ? $premium = 0 : $premium = '₹ ' .format_indian_number($self_premium); - empty($self_gst) ? $gst_forself = 0 : $gst_forself = '₹ ' .format_indian_number($self_gst); - - }else{ + if ($policy_premium_data['premium_type'] == 1) { - $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); - $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); - + empty($self_premium) ? $premium = 0 : $premium = '₹ ' . format_indian_number($self_premium); + empty($self_gst) ? $gst_forself = 0 : $gst_forself = '₹ ' . format_indian_number($self_gst); + } else { + + $premium = '₹ ' . format_indian_number(round($inner_item['rata_premimum'])); + $gst_forself = '₹ ' . format_indian_number(round($inner_item['gst'])); } - + $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; $temp_data .= '' . $inner_item['relationship'] . ''; $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; - + // dd($si); // Premium summery for show and hide the Additional premium data - if($inner_item['payable_employee'] == 1 || $client_policy_data['is_premium_summery'] == 1){ - if($policy_premium_data['premium_type'] == 2){ + if ($inner_item['payable_employee'] == 1 || $client_policy_data['is_premium_summery'] == 1) { + if ($policy_premium_data['premium_type'] == 2) { $temp_data .= '' . $si . ''; $temp_data .= '' . $premium . ''; $temp_data .= '' . $gst_forself . ''; + } else { - }else{ + if ($policy_premium_data['premium_type'] == 1) { - if($policy_premium_data['premium_type'] == 1){ + $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . '') : ($si == 0 ? "" : '' . $si . '')); + $temp_data .= (($premium != 0 && count($item) != 1) ? ('' . $premium . '') : ($premium == 0 ? "" : '' . $premium . '')); + $temp_data .= (($gst_forself != 0 && count($item) != 1) ? ('' . $gst_forself . '') : ($gst_forself == 0 ? "" : '' . $gst_forself . '')); + } else { - $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . '') : ($si == 0 ? "" : '' . $si . '') ); - $temp_data .= (($premium != 0 && count($item) != 1) ? ('' . $premium . '') : ($premium == 0 ? "" : '' . $premium . '') ); - $temp_data .= (($gst_forself != 0 && count($item) != 1) ? ('' . $gst_forself . '') : ($gst_forself == 0 ? "" : '' . $gst_forself . '') ); - - }else{ - - $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . '') : ($si == 0 ? "" : '' . $si . '') ); + $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . '') : ($si == 0 ? "" : '' . $si . '')); $temp_data .= '' . $premium . ''; - $temp_data .= '' . $gst_forself . ''; + $temp_data .= '' . $gst_forself . ''; } $self_si_amount = 0; $self_premium = 0; $self_gst = 0; } - }else{ + } else { $temp_data .= '' . $si . ''; } - + $temp_data .= ''; - + $is_addon = $inner_item['is_addon']; - + $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium; $gst = $inner_item['gst'] + $gst; } $policy_name_for_policy_type = $inner_item['policy_name']; - if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){ + if ($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3) { $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents'; } - + $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee )

'; $table_content .= ''; - + // Add text-align: center to the table head $table_content .= ''; $table_content .= ''; @@ -459,20 +478,20 @@ class sendMailNotification $table_content .= ''; // Premium summery for show and hide the Additional premium data - if($inner_item['payable_employee'] == 1 || $client_policy_data['is_premium_summery'] == 1){ + if ($inner_item['payable_employee'] == 1 || $client_policy_data['is_premium_summery'] == 1) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; - + // Add text-align: center to the table body $table_content .= '' . $temp_data . ''; $table_content .= '
Sum InsuredPremiumGST
'; - + // Premium summery for show and hide the Additional premium data - if($inner_item['payable_employee'] == 1 || $client_policy_data['is_premium_summery'] == 1){ + if ($inner_item['payable_employee'] == 1 || $client_policy_data['is_premium_summery'] == 1) { $addon_list_array = [ 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )', 'addtional_premium' => round($addtional_premium), @@ -481,18 +500,17 @@ class sendMailNotification $Addon_list[] = $addon_list_array; } - + $temp_data = ''; $addtional_premium = 0; $gst = 0; - } } - + if (count($Addon_list) > 0) { $table_content .= '
'; $table_content .= ''; - + // Center align for table header and body $table_content .= ''; $table_content .= ''; @@ -502,14 +520,14 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + $table_content .= ''; - + $sum_total = 0; foreach ($Addon_list as $key => $value) { $total_addon = $value['gst'] + $value['addtional_premium']; $sum_total += $total_addon; - + $table_content .= ''; $table_content .= ''; $table_content .= ''; @@ -517,7 +535,7 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; } - + $sum_total_words = numberToWords($sum_total); $table_content .= ''; $table_content .= ''; @@ -527,56 +545,63 @@ class sendMailNotification $table_content .= '
Total
' . $value['policy_name'] . '₹' . format_indian_number($value['addtional_premium']) . '₹' . format_indian_number($total_addon) . '
Total
'; // $table_content .= '
' . $sum_total_words . '
'; } - + // dd($payable_employee_array, $Addon_list); // print_r($table_content); die; - $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')' , $mail_content); + $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')', $mail_content); $mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $employee_mobile_no, $mail_content); - $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content, $mail_content); + + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); - // print_r($mail_content); die; + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); - $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; + + $wholeData[] = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; return $wholeData; - } + } else if ($action == 'account_maneger_summary_mail') { - } else if($action == 'account_maneger_summary_mail'){ - $client_id = $params['client_id']; $client_policy_id = $params['client_policy_id']; $common = $params['common']; $clientModel = new ClientModel(); $notificationModel = new NotificationModel(); - $clientRMModel =new ClientRMModel(); + $clientRMModel = new ClientRMModel(); $clientPolicyModel = new ClientPolicyModel(); $PolicyPremium1Model = new PolicyPremium1Model(); $PolicyPremium2Model = new PolicyPremium2Model(); - $client_data =$clientModel->where('id', $client_id)->first(); - $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); + $client_data = $clientModel->where('id', $client_id)->first(); - if (isset($notification_data) && $notification_data['enabled'] == 1) { + $params['client_data'] = $client_data; - $client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll(); - $user_list= []; + $notification_data = $notificationModel->where('client_id', $client_id)->where('template_name', $action)->first(); + + if (isset($notification_data) && $notification_data['enabled'] == 1) { + + $client_rm_data = $clientRMModel->where('client_id', $client_id)->where('is_active', 1)->findAll(); + $user_list = []; foreach ($client_rm_data as $key => $value) { - if($value['level'] == 3){ + if ($value['level'] == 3) { $userModel = new UserModel(); $user_data = $userModel->where('id', $value['user_id'])->first(); - $user_list[]=$user_data; + $user_list[] = $user_data; } } - + $mail_content = $notification_data['mail_content']; $subject = $notification_data['subject']; $app_link = $_ENV['App_Url']; $nhance_logo = $_ENV['NHANCE_LOGO']; - + $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; // $client_logo = $nhance_logo; @@ -603,24 +628,24 @@ class sendMailNotification $temp_data = ''; $policy_name = ''; $is_addon = ''; - + foreach ($item as $inner_item) { //getting policy premium data $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first(); - if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){ + if ($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7) { $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); - }else{ + } else { $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); } //end of getting policy premium data - if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){ + if ($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2) { $payable_employee_array[] = $inner_item; } $policy_name = $inner_item['policy_name']; - + if ($inner_item['relationship'] == 'Self') { $emp_code = ' (' . $inner_item['emp_code'] . ')'; } else { @@ -631,27 +656,27 @@ class sendMailNotification $premium = ''; $gst_forself = ''; // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ - $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); - $premium = '₹ ' .format_indian_number(round($inner_item['premium'])); - $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); + $si = '₹ ' . format_indian_number($inner_item['basic_cover_si']); + $premium = '₹ ' . format_indian_number(round($inner_item['premium'])); + $gst_forself = '₹ ' . format_indian_number(round($inner_item['gst'])); // } - + $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . $emp_code . ''; $temp_data .= '' . $inner_item['relationship'] . ''; $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; $temp_data .= '' . $si . ''; - + // Only Display SI Topup and Dependent Addon if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { $temp_data .= '' . $premium . ''; $temp_data .= '' . $gst_forself . ''; } - + $temp_data .= ''; - + $is_addon = $inner_item['is_addon']; - + if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium; $gst = $inner_item['gst'] + $gst; @@ -659,13 +684,13 @@ class sendMailNotification } $policy_name_for_policy_type = $inner_item['policy_name']; - if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){ + if ($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3) { $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents'; } - + $table_content .= $policy_name_for_policy_type . ''; $table_content .= ''; - + // Add text-align: center to the table head $table_content .= ''; $table_content .= ''; @@ -673,20 +698,20 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + // Only Display SI Topup and Dependent Addon if ($is_addon == 2 || $is_addon == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; - + // Add text-align: center to the table body $table_content .= '' . $temp_data . ''; $table_content .= '
RelationDate Of BirthSum InsuredPremiumGST
'; - + if ($is_addon == 2 || $is_addon == 3) { $addon_list_array = [ 'policy_name' => $policy_name_for_policy_type, @@ -695,26 +720,26 @@ class sendMailNotification ]; $Addon_list[] = $addon_list_array; } - + $temp_data = ''; $addtional_premium = 0; $gst = 0; } - if(count($payable_employee_array) > 0){ + if (count($payable_employee_array) > 0) { $table_content .= '

Policy Type :'; $temp_data = ''; $is_addon = ''; - + foreach ($payable_employee_array as $inner_item) { //getting policy premium data $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first(); - if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){ + if ($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7) { $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); - }else{ + } else { $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); } //end of getting policy premium data @@ -723,11 +748,11 @@ class sendMailNotification $si = ''; $premium = ''; $gst_forself = ''; - - $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); - $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); - $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); - + + $si = '₹ ' . format_indian_number($inner_item['basic_cover_si']); + $premium = '₹ ' . format_indian_number(round($inner_item['rata_premimum'])); + $gst_forself = '₹ ' . format_indian_number(round($inner_item['gst'])); + $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; $temp_data .= '' . $inner_item['relationship'] . ''; @@ -735,23 +760,23 @@ class sendMailNotification $temp_data .= '' . $si . ''; $temp_data .= '' . $premium . ''; $temp_data .= '' . $gst_forself . ''; - + $temp_data .= ''; - + $is_addon = $inner_item['is_addon']; - + $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium; $gst = $inner_item['gst'] + $gst; } $policy_name_for_policy_type = $inner_item['policy_name']; - if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){ + if ($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3) { $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents'; } - + $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee )

'; $table_content .= ''; - + // Add text-align: center to the table head $table_content .= ''; $table_content .= ''; @@ -761,15 +786,15 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + $table_content .= ''; $table_content .= ''; - + // Add text-align: center to the table body $table_content .= '' . $temp_data . ''; $table_content .= '
Sum InsuredPremiumGST
'; - - + + $addon_list_array = [ 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )', 'addtional_premium' => round($addtional_premium), @@ -777,19 +802,17 @@ class sendMailNotification ]; $Addon_list[] = $addon_list_array; - + $temp_data = ''; $addtional_premium = 0; $gst = 0; - } - } - + if (count($Addon_list) > 0) { $table_content .= '
'; $table_content .= ''; - + // Center align for table header and body $table_content .= ''; $table_content .= ''; @@ -799,14 +822,14 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + $table_content .= ''; - + $sum_total = 0; foreach ($Addon_list as $key => $value) { $total_addon = $value['gst'] + $value['addtional_premium']; $sum_total += $total_addon; - + $table_content .= ''; $table_content .= ''; $table_content .= ''; @@ -814,7 +837,7 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; } - + $sum_total_words = numberToWords($sum_total); $table_content .= ''; $table_content .= ''; @@ -824,28 +847,35 @@ class sendMailNotification $table_content .= '
Total
' . $value['policy_name'] . '₹' . format_indian_number($value['addtional_premium']) . '₹' . format_indian_number($total_addon) . '
Total
'; // $table_content .= '
' . $sum_total_words . '
'; } - - - $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + + + $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content, $mail_content); $account_manager_mail_list = []; - if(isset($user_list)){ + if (isset($user_list)) { foreach ($user_list as $key => $value) { - $full_name = $value['first_name'] .' ' .$value['last_name']; - $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $full_name , $mail_content); + $full_name = $value['first_name'] . ' ' . $value['last_name']; + $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $full_name, $mail_content); - $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common]; + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + + $wholeData[] = ['mail' => $value['email'], 'subject' => $subject, 'message' => $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common]; // $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'}}; } return $wholeData; } - } + } } //else if($action == 'client_hr_summary_mail'){ // $client_id = $params['client_id']; // $client_policy_id = $params['client_policy_id']; // $common = $params['common']; - +data: name: name: // $clientModel = new ClientModel(); // $clientPolicyModel = new ClientPolicyModel(); // $PolicyPremium1Model = new PolicyPremium1Model(); @@ -867,17 +897,17 @@ class sendMailNotification // $user_list[]=$user_data; // } // } - - + + // $mail_content = $notification_data['mail_content']; // $subject = $notification_data['subject']; // $app_link = $_ENV['App_Url']; // $nhance_logo = $_ENV['NHANCE_LOGO']; - + // $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; // // $client_logo = $nhance_logo; - + // $mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "Nhance Logo", $mail_content); // $mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "Client Logo", $mail_content); // $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); @@ -891,7 +921,7 @@ class sendMailNotification // $gst = 0; // $array_list = $params['array_list']; // $Addon_list = []; - + // foreach ($array_list as $item) { // $payable_employee_array = []; @@ -901,7 +931,7 @@ class sendMailNotification // $temp_data = ''; // $policy_name = ''; // $is_addon = ''; - + // foreach ($item as $inner_item) { // //getting policy premium data @@ -918,7 +948,7 @@ class sendMailNotification // } // $policy_name = $inner_item['policy_name']; - + // if ($inner_item['relationship'] == 'Self') { // $emp_code = ' (' . $inner_item['emp_code'] . ')'; // } else { @@ -936,29 +966,29 @@ class sendMailNotification // $premium = '₹ ' .format_indian_number(round($inner_item['premium'])); // $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); // // } - + // $temp_data .= ''; // $temp_data .= '' . $inner_item['name'] . $emp_code . ''; // $temp_data .= '' . $inner_item['relationship'] . ''; // $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; // $temp_data .= '' . $si . ''; - + // // Only Display SI Topup and Dependent Addon // if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { // $temp_data .= '' . $premium . ''; // $temp_data .= '' . $gst_forself . ''; // } - + // $temp_data .= ''; - + // $is_addon = $inner_item['is_addon']; - + // if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { // $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium; // $gst = $inner_item['gst'] + $gst; // } // } - + // $policy_name_for_policy_type = $inner_item['policy_name']; // if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){ // $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents'; @@ -966,7 +996,7 @@ class sendMailNotification // $table_content .= $policy_name_for_policy_type . ''; // $table_content .= ''; - + // // Add text-align: center to the table head // $table_content .= ''; // $table_content .= ''; @@ -974,20 +1004,20 @@ class sendMailNotification // $table_content .= ''; // $table_content .= ''; // $table_content .= ''; - + // // Only Display SI Topup and Dependent Addon // if ($is_addon == 2 || $is_addon == 3) { // $table_content .= ''; // $table_content .= ''; // } - + // $table_content .= ''; // $table_content .= ''; - + // // Add text-align: center to the table body // $table_content .= '' . $temp_data . ''; // $table_content .= '
RelationDate Of BirthSum InsuredPremiumGST
'; - + // if ($is_addon == 2 || $is_addon == 3) { // $addon_list_array = [ // 'policy_name' => $policy_name_for_policy_type, @@ -996,7 +1026,7 @@ class sendMailNotification // ]; // $Addon_list[] = $addon_list_array; // } - + // $temp_data = ''; // $addtional_premium = 0; // $gst = 0; @@ -1007,7 +1037,7 @@ class sendMailNotification // $table_content .= '

Policy Type :'; // $temp_data = ''; // $is_addon = ''; - + // foreach ($payable_employee_array as $inner_item) { @@ -1024,11 +1054,11 @@ class sendMailNotification // $si = ''; // $premium = ''; // $gst_forself = ''; - + // $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); // $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); // $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); - + // $temp_data .= ''; // $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; // $temp_data .= '' . $inner_item['relationship'] . ''; @@ -1036,11 +1066,11 @@ class sendMailNotification // $temp_data .= '' . $si . ''; // $temp_data .= '' . $premium . ''; // $temp_data .= '' . $gst_forself . ''; - + // $temp_data .= ''; - + // $is_addon = $inner_item['is_addon']; - + // $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium; // $gst = $inner_item['gst'] + $gst; // } @@ -1049,10 +1079,10 @@ class sendMailNotification // if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){ // $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents'; // } - + // $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee )

'; // $table_content .= ''; - + // // Add text-align: center to the table head // $table_content .= ''; // $table_content .= ''; @@ -1062,15 +1092,15 @@ class sendMailNotification // $table_content .= ''; // $table_content .= ''; // $table_content .= ''; - + // $table_content .= ''; // $table_content .= ''; - + // // Add text-align: center to the table body // $table_content .= '' . $temp_data . ''; // $table_content .= '
Sum InsuredPremiumGST
'; - - + + // $addon_list_array = [ // 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )', // 'addtional_premium' => round($addtional_premium), @@ -1078,18 +1108,18 @@ class sendMailNotification // ]; // $Addon_list[] = $addon_list_array; - + // $temp_data = ''; // $addtional_premium = 0; // $gst = 0; // } // } - + // if (count($Addon_list) > 0) { // $table_content .= '
'; // $table_content .= ''; - + // // Center align for table header and body // $table_content .= ''; // $table_content .= ''; @@ -1099,14 +1129,14 @@ class sendMailNotification // $table_content .= ''; // $table_content .= ''; // $table_content .= ''; - + // $table_content .= ''; - + // $sum_total = 0; // foreach ($Addon_list as $key => $value) { // $total_addon = $value['gst'] + $value['addtional_premium']; // $sum_total += $total_addon; - + // $table_content .= ''; // $table_content .= ''; // $table_content .= ''; @@ -1114,7 +1144,7 @@ class sendMailNotification // $table_content .= ''; // $table_content .= ''; // } - + // $sum_total_words = numberToWords($sum_total); // $table_content .= ''; // $table_content .= ''; @@ -1124,7 +1154,7 @@ class sendMailNotification // $table_content .= '
Total
' . $value['policy_name'] . '₹' . format_indian_number($value['addtional_premium']) . '₹' . format_indian_number($total_addon) . '
Total
'; // // $table_content .= '
' . $sum_total_words . '
'; // } - + // $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); @@ -1133,6 +1163,26 @@ class sendMailNotification // $mail_array = array_map('trim', $mail_array); // $wholeData = []; // foreach ($mail_array as $key => $value) { + // + // + // $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + // $data['params'] = $params; + // $data['mail_content'] = $mail_content; + // $mail_content = view('mail_template',$data); + // $mail_content = $header_of_mail . + // '
+ // + + // + // + // + //
+ // ' . $mail_content . ' + //
+ //
' . $footer_of_mail; + // $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common]; // // $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'}}; // } @@ -1141,11 +1191,11 @@ class sendMailNotification // } // } - } - + } + public static function sendMailNotificationForTesting($action, $params) { - $wholeData =[]; + $wholeData = []; if ($action == 'member_welcome_mail') { @@ -1156,15 +1206,15 @@ class sendMailNotification $mail = $params['test_mail']; $mail_content = $notification['mail_content']; - $subject = $notification['subject']; - + $subject = $notification['subject']; + $mailAttachmentModel = new MailAttachmentModel(); $attachment_data = $mailAttachmentModel - ->select('file_path, file_name') - ->where('notification_id', $notification['id']) - ->where('is_active', 1) - ->findAll(); - + ->select('file_path, file_name') + ->where('notification_id', $notification['id']) + ->where('is_active', 1) + ->findAll(); + $attachments = []; foreach ($attachment_data as $data) { $attachments[] = [ @@ -1172,7 +1222,7 @@ class sendMailNotification "fileName" => $data['file_name'] ]; } - + // print_r($attachments); die; $employee_name = 'John Doe'; @@ -1190,21 +1240,30 @@ class sendMailNotification $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); $mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "Review Details", $mail_content); - - if ($mail != null || $mail != '') { - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments]; - } - - return $wholeData; - } else if($action == 'member_reminder_mail'){ + if ($mail != null || $mail != '') { + + // + // + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments]; + } + + return $wholeData; + } else if ($action == 'member_reminder_mail') { $notification_data = $params['notification_data']; $client_data = $params['client_data']; $mail = $params['test_mail']; $mail_content = $notification_data['mail_content']; - $subject = $notification_data['subject']; + $subject = $notification_data['subject']; $nhance_logo = $_ENV['NHANCE_LOGO']; $app_link = $_ENV['App_Url']; @@ -1224,26 +1283,31 @@ class sendMailNotification if ((isset($notification_data) && $notification_data['enabled'] == 1)) { if (isset($mail) && !empty($mail)) { - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; - } + + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; + } } return $wholeData; - - - } else if($action == 'member_ecard_mail'){ + } else if ($action == 'member_ecard_mail') { $notification = $params['notification_data']; $client_data = $params['client_data']; $mail = $params['test_mail']; $mailAttachmentModel = new MailAttachmentModel(); $attachment_data = $mailAttachmentModel - ->select('file_path, file_name') - ->where('notification_id', $notification['id']) - ->where('is_active', 1) - ->findAll(); - + ->select('file_path, file_name') + ->where('notification_id', $notification['id']) + ->where('is_active', 1) + ->findAll(); + $attachments = []; foreach ($attachment_data as $data) { $attachments[] = [ @@ -1254,7 +1318,7 @@ class sendMailNotification $mail_content = $notification['mail_content']; $subject = $notification['subject']; - + $rand_string = 'HX3kUh'; $link = generate_download_link($rand_string); @@ -1264,9 +1328,9 @@ class sendMailNotification $nhance_logo = $_ENV['NHANCE_LOGO']; $app_link = $_ENV['App_Url']; $post_enrollment_app_link = $_ENV['POST_ENROLLMENT_APP_LINK']; - + $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; - + $mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "Nhance Logo", $mail_content); $mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "Client Logo", $mail_content); @@ -1277,26 +1341,34 @@ class sendMailNotification $mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "Download Insurance Card", $mail_content); $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'],'attachments' => $attachments, 'reply_to' => $client_data['reply_to']]; + + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'attachments' => $attachments, 'reply_to' => $client_data['reply_to']]; return $wholeData; - - } else if($action == 'member_review_and_summary_mail'){ + } else if ($action == 'member_review_and_summary_mail') { $array_list = [ - 'policy_name' => 'Health Insurance Plan', - 'emp_code' => 'E12345', - 'name' => 'John Doe', - 'relationship' => 'Self', - 'dob' => '1985-05-15', - 'basic_cover_si' => 500000, - 'premium' => 12000, - 'gst' => 2160, - 'rata_premimum' => 12000, - 'is_addon' => 2, - 'mobile' => 9080706050 + 'policy_name' => 'Health Insurance Plan', + 'emp_code' => 'E12345', + 'name' => 'John Doe', + 'relationship' => 'Self', + 'dob' => '1985-05-15', + 'basic_cover_si' => 500000, + 'premium' => 12000, + 'gst' => 2160, + 'rata_premimum' => 12000, + 'is_addon' => 2, + 'mobile' => 9080706050 ]; - + $notification_data = $params['notification_data']; $client_data = $params['client_data']; @@ -1309,7 +1381,7 @@ class sendMailNotification $app_link = $_ENV['App_Url']; $nhance_logo = $_ENV['NHANCE_LOGO']; - + $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); @@ -1326,19 +1398,19 @@ class sendMailNotification $name = $array_list['name']; $mobile = $array_list['mobile']; $emp_code = ''; - + if (!empty($array_list)) { $table_content .= '

Policy Type :'; - + $policy_name = $array_list['policy_name']; - + if ($array_list['relationship'] == 'Self') { $emp_code = ' (' . $array_list['emp_code'] . ')'; } else { $emp_code = ''; } - + // Start table row $table_content .= $policy_name . '

'; $table_content .= ''; @@ -1348,16 +1420,16 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + // Only Display SI Topup and Dependent Addon if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; - + // Table body with details $table_content .= ''; $table_content .= ''; @@ -1365,21 +1437,21 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; $table_content .= '
RelationDate Of BirthSum InsuredPremiumGST
' . $array_list['relationship'] . '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '₹' . format_indian_number($array_list['basic_cover_si']) . '₹' . format_indian_number(round($array_list['premium'])) . '₹' . format_indian_number(round($array_list['gst'])) . '
'; - + // Calculate additional premium and GST if applicable if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { $addtional_premium = $array_list['rata_premimum']; $gst = $array_list['gst']; - + // Prepare addon summary $addon_list_array = [ 'policy_name' => $policy_name, @@ -1389,12 +1461,12 @@ class sendMailNotification $Addon_list[] = $addon_list_array; } - + // Generate summary table for addon if applicable if (count($Addon_list) > 0) { $table_content .= '
'; $table_content .= ''; - + $table_content .= ''; $table_content .= ''; $table_content .= ''; @@ -1403,9 +1475,9 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + $table_content .= ''; - + $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; $table_content .= ''; $table_content .= ''; @@ -1413,7 +1485,7 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + $sum_total_words = numberToWords($total_addon); $table_content .= ''; $table_content .= ''; @@ -1422,20 +1494,26 @@ class sendMailNotification $table_content .= ''; $table_content .= '
Policy NameTotal
' . $Addon_list[0]['policy_name'] . '₹' . format_indian_number($Addon_list[0]['gst']) . '₹' . format_indian_number($total_addon) . '
Total
'; } - } - - $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')' , $mail_content); + } + + $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')', $mail_content); $mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $mobile, $mail_content); - $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content, $mail_content); + + + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; return $wholeData; - } - - } else if($action == 'account_maneger_summary_mail'){ + } else if ($action == 'account_maneger_summary_mail') { $array_list = [ 'policy_name' => 'Health Insurance Plan', @@ -1454,14 +1532,14 @@ class sendMailNotification $client_data = $params['client_data']; $mail = $params['test_mail']; - if (isset($notification_data) && $notification_data['enabled'] == 1) { - + if (isset($notification_data) && $notification_data['enabled'] == 1) { + $mail_content = $notification_data['mail_content']; $subject = $notification_data['subject']; $app_link = $_ENV['App_Url']; $nhance_logo = $_ENV['NHANCE_LOGO']; - + $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); @@ -1477,18 +1555,18 @@ class sendMailNotification $Addon_list = []; $name = $array_list['name']; $emp_code = ''; - + if (!empty($array_list)) { $table_content .= '

Policy Type :'; - + $policy_name = $array_list['policy_name']; - + if ($array_list['relationship'] == 'Self') { $emp_code = ' (' . $array_list['emp_code'] . ')'; } else { $emp_code = ''; } - + // Start table row $table_content .= $policy_name . '

'; $table_content .= ''; @@ -1498,16 +1576,16 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + // Only Display SI Topup and Dependent Addon if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; - + // Table body with details $table_content .= ''; $table_content .= ''; @@ -1515,21 +1593,21 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; $table_content .= '
RelationDate Of BirthSum InsuredPremiumGST
' . $array_list['relationship'] . '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '₹' . format_indian_number($array_list['basic_cover_si']) . '₹' . format_indian_number(round($array_list['premium'])) . '₹' . format_indian_number(round($array_list['gst'])) . '
'; - + // Calculate additional premium and GST if applicable if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { $addtional_premium = $array_list['rata_premimum']; $gst = $array_list['gst']; - + // Prepare addon summary $addon_list_array = [ 'policy_name' => $policy_name, @@ -1539,12 +1617,12 @@ class sendMailNotification $Addon_list[] = $addon_list_array; } - + // Generate summary table for addon if applicable if (count($Addon_list) > 0) { $table_content .= '
'; $table_content .= ''; - + $table_content .= ''; $table_content .= ''; $table_content .= ''; @@ -1553,9 +1631,9 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + $table_content .= ''; - + $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; $table_content .= ''; $table_content .= ''; @@ -1563,7 +1641,7 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + $sum_total_words = numberToWords($total_addon); $table_content .= ''; $table_content .= ''; @@ -1572,17 +1650,25 @@ class sendMailNotification $table_content .= ''; $table_content .= '
Policy NameTotal
' . $Addon_list[0]['policy_name'] . '₹' . format_indian_number($Addon_list[0]['gst']) . '₹' . format_indian_number($total_addon) . '
Total
'; } - } + } - $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')' , $mail_content); - $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')', $mail_content); + $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content, $mail_content); - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'reply_to' => $client_data['reply_to']]; + return $wholeData; } - - } else if($action == 'client_hr_summary_mail'){ + } else if ($action == 'client_hr_summary_mail') { $array_list = [ 'policy_name' => 'Health Insurance Plan', @@ -1601,16 +1687,16 @@ class sendMailNotification $client_data = $params['client_data']; $mail = $params['test_mail']; - if (isset($notification_data['enabled']) && $notification_data['enabled'] == 1) { - + if (isset($notification_data['enabled']) && $notification_data['enabled'] == 1) { + $mail_content = $notification_data['mail_content']; $subject = $notification_data['subject']; $app_link = $_ENV['App_Url']; $nhance_logo = $_ENV['NHANCE_LOGO']; - + $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; - + $mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "Nhance Logo", $mail_content); $mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "Client Logo", $mail_content); $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); @@ -1624,19 +1710,19 @@ class sendMailNotification $Addon_list = []; $name = $array_list['name']; $emp_code = ''; - + if (!empty($array_list)) { - + $table_content .= '

Policy Type :'; - + $policy_name = $array_list['policy_name']; - + if ($array_list['relationship'] == 'Self') { $emp_code = ' (' . $array_list['emp_code'] . ')'; } else { $emp_code = ''; } - + // Start table row $table_content .= $policy_name . '

'; $table_content .= ''; @@ -1646,16 +1732,16 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + // Only Display SI Topup and Dependent Addon if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; - + // Table body with details $table_content .= ''; $table_content .= ''; @@ -1663,21 +1749,21 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; $table_content .= '
RelationDate Of BirthSum InsuredPremiumGST
' . $array_list['relationship'] . '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '₹' . format_indian_number($array_list['basic_cover_si']) . '₹' . format_indian_number(round($array_list['premium'])) . '₹' . format_indian_number(round($array_list['gst'])) . '
'; - + // Calculate additional premium and GST if applicable if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { $addtional_premium = $array_list['rata_premimum']; $gst = $array_list['gst']; - + // Prepare addon summary $addon_list_array = [ 'policy_name' => $policy_name, @@ -1687,13 +1773,13 @@ class sendMailNotification $Addon_list[] = $addon_list_array; } - + // Generate summary table for addon if applicable if (count($Addon_list) > 0) { $table_content .= '
'; $table_content .= ''; - + $table_content .= ''; $table_content .= ''; $table_content .= ''; @@ -1702,9 +1788,9 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + $table_content .= ''; - + $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; $table_content .= ''; $table_content .= ''; @@ -1712,7 +1798,7 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - + $sum_total_words = numberToWords($total_addon); $table_content .= ''; $table_content .= ''; @@ -1721,17 +1807,23 @@ class sendMailNotification $table_content .= ''; $table_content .= '
Policy NameTotal
' . $Addon_list[0]['policy_name'] . '₹' . format_indian_number($Addon_list[0]['gst']) . '₹' . format_indian_number($total_addon) . '
Total
'; } - } - - $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')' , $mail_content); - $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + } + + $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')', $mail_content); + $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content, $mail_content); - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'reply_to' => $client_data['reply_to']]; return $wholeData; } - - } - } -} \ No newline at end of file + } + } +} diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php index 2272c30..2fcf0ce 100755 --- a/app/Views/DashBoard.php +++ b/app/Views/DashBoard.php @@ -184,8 +184,6 @@ body {
- -