3168 lines
173 KiB
PHP
Executable File
3168 lines
173 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Helpers;
|
|
|
|
use App\Models\ClientModel;
|
|
use App\Models\ClientPolicyModel;
|
|
use App\Models\ClientRMModel;
|
|
use App\Models\NotificationModel;
|
|
use App\Models\UserModel;
|
|
use App\Models\EmployeeModel;
|
|
use App\Models\PolicyPremium1Model;
|
|
use App\Models\PolicyPremium2Model;
|
|
use App\Models\MailAttachmentModel;
|
|
use Kint\Kint;
|
|
|
|
// send mail notification
|
|
class sendMailNotification
|
|
{
|
|
public static function sendMailNotification($action, $params)
|
|
{
|
|
$wholeData = [];
|
|
|
|
if ($action == 'member_welcome_mail') {
|
|
|
|
$dataToInsert = $params['dataToInsert'];
|
|
$notification = $params['notification'];
|
|
$client_data = $params['client_data'];
|
|
$common = $params['common'];
|
|
|
|
$mailAttachmentModel = new MailAttachmentModel();
|
|
$attachment_data = $mailAttachmentModel
|
|
->select('file_path, file_name')
|
|
->where('notification_id', $notification['id'])
|
|
->where('is_active', 1)
|
|
->findAll();
|
|
|
|
$attachments = [];
|
|
foreach ($attachment_data as $data) {
|
|
$attachments[] = [
|
|
"filePath" => WRITEPATH . $data['file_path'],
|
|
"fileName" => $data['file_name']
|
|
];
|
|
}
|
|
|
|
$mail = $dataToInsert['email_corporate'];
|
|
$subject = $notification['subject'];
|
|
$app_link = $_ENV['App_Url'];
|
|
$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'];
|
|
|
|
$enrollment_open_date = !empty($params['enrollment_open_date'] ?? null)
|
|
? change_date_format($params['enrollment_open_date'], 'Y-m-d', 'F d, Y')
|
|
: 'N/A';
|
|
|
|
$enrollment_close_date = !empty($params['enrollment_close_date'] ?? null)
|
|
? change_date_format($params['enrollment_close_date'], 'Y-m-d', 'F d, Y')
|
|
: 'N/A';
|
|
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$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_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
|
|
$mail_content = str_replace(["[[enrollment_open_date]]", "{{enrollment_open_date}}"], $enrollment_open_date, $mail_content);
|
|
$mail_content = str_replace(["[[enrollment_close_date]]", "{{enrollment_close_date}}"], $enrollment_close_date, $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') {
|
|
|
|
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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'];
|
|
$notification_data = $params['notification_data'];
|
|
$client_data = $params['client_data'];
|
|
$common = $params['common'];
|
|
|
|
$mailAttachmentModel = new MailAttachmentModel();
|
|
$attachment_data = $mailAttachmentModel
|
|
->select('file_path, file_name')
|
|
->where('notification_id', $notification_data['id'])
|
|
->where('is_active', 1)
|
|
->findAll()??[];
|
|
|
|
$attachments = [];
|
|
foreach ($attachment_data as $data) {
|
|
$attachments[] = [
|
|
"filePath" => WRITEPATH . $data['file_path'],
|
|
"fileName" => $data['file_name']
|
|
];
|
|
}
|
|
|
|
$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}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
$mail_content = str_replace(["[[policy_no]]", "{{policy_no}}"], $emp_data['policy_no'] ?? '', $mail_content);
|
|
$mail_content = str_replace(["[[emp_code]]", "{{emp_code}}"], $emp_data['emp_code'] ?? '', $mail_content);
|
|
$mail_content = str_replace(["[[employee_name]]", "{{employee_name}}"], $emp_data['name'] ?? '', $mail_content);
|
|
$mail_content = str_replace(["[[employee_mobile]]", "{{employee_mobile}}"], $emp_data['mobile'] ?? '', $mail_content);
|
|
//convert to dd-mm-yyyy format
|
|
$emp_data['enrollment_open_date'] = date('d-m-Y', strtotime($emp_data['enrollment_open_date']));
|
|
$emp_data['enrollment_close_date'] = date('d-m-Y', strtotime($emp_data['enrollment_close_date']));
|
|
$mail_content = str_replace(["[[enrollment_open_date]]", "{{enrollment_open_date}}"], $emp_data['enrollment_open_date'] ?? '', $mail_content);
|
|
$mail_content = str_replace(["[[enrollment_close_date]]", "{{enrollment_close_date}}"], $emp_data['enrollment_close_date'] ?? '', $mail_content);
|
|
|
|
|
|
|
|
$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_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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'], 'common' => $common];
|
|
|
|
return $wholeData;
|
|
} else if ($action == 'member_ecard_mail') {
|
|
|
|
$notification = $params['notification'];
|
|
$get_emp_email_and_other_details = $params['get_emp_email_and_other_details'];
|
|
$rand_string = $params['rand_string'];
|
|
$client_data = $params['client_data'];
|
|
$tpa_id = $params['tpa_id'];
|
|
$common = $params['common'];
|
|
|
|
|
|
$mail_content = $notification['mail_content'];
|
|
$mail = $get_emp_email_and_other_details['email_corporate'];
|
|
$subject = $notification['subject'];
|
|
|
|
$cleanedText = mb_convert_encoding($subject, 'UTF-8', 'UTF-8'); // Normalize encoding
|
|
$cleanedText = preg_replace('/[^\x20-\x7E]/', '', $cleanedText);
|
|
|
|
$subject = $cleanedText;
|
|
|
|
$link = generate_download_link($rand_string) . '/1';
|
|
|
|
$app_link = $_ENV['App_Url'];
|
|
$name = $get_emp_email_and_other_details['name'];
|
|
$employee_mobile_no = $get_emp_email_and_other_details['mobile'];
|
|
$mail_content = $notification['mail_content'];
|
|
|
|
$nhance_logo = $_ENV['NHANCE_LOGO'];
|
|
// 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}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
|
|
$mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name, $mail_content);
|
|
$mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $employee_mobile_no, $mail_content);
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
$mail_content = str_replace(["[[post_enrollment_app_link]]", "{{post_enrollment_app_link}}"], "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content);
|
|
// $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content);
|
|
$mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "<a href='$link/1'>Download Insurance Card</a>", $mail_content);
|
|
$mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
|
|
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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') {
|
|
|
|
$array_list = $params['array_list']; //employeee lst
|
|
$client_policy_id = $params['client_policy_id'];
|
|
$emp_code = $params['emp_code'];
|
|
$client_id = $params['client_id'];
|
|
$common = $params['common'];
|
|
|
|
$clientModel = new ClientModel();
|
|
$notificationModel = new NotificationModel();
|
|
$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();
|
|
|
|
$params['client_data'] = $client_data;
|
|
// dd($notification_data);
|
|
|
|
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'];
|
|
// $client_logo = $nhance_logo;
|
|
|
|
$mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
// Step 1: Replace the placeholder with an HTML table structure
|
|
$mail = '';
|
|
$table_content = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
$Addon_list = [];
|
|
$name = '';
|
|
$employee_mobile_no = '';
|
|
$emp_code = '';
|
|
// is_premium_summery: 0=hide all, 1=full premium/GST + summary, 2=hide columns but summary as Policy Name/Total
|
|
$show_full_premium_breakdown = false;
|
|
|
|
// echo '<pre>';
|
|
// dd($array_list); die;
|
|
|
|
|
|
|
|
foreach ($array_list as $item) {
|
|
|
|
$payable_employee_array = [];
|
|
|
|
if (count($item) != 0) {
|
|
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
$temp_data = '';
|
|
$policy_name = '';
|
|
$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) {
|
|
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
} 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) {
|
|
$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'] . ')';
|
|
$emp_code = ' ( Employee Code : ' . $inner_item['emp_code'] . ')';
|
|
$mail = $inner_item['email_corporate'];
|
|
$name = $inner_item['name'];
|
|
$employee_mobile_no = $inner_item['mobile'];
|
|
}
|
|
|
|
$si = '';
|
|
$premium = '';
|
|
$gst_forself = '';
|
|
$is_premium_summery = (int) ($client_policy_data['is_premium_summery'] ?? 0);
|
|
$show_premium_columns = ($is_premium_summery === 1);
|
|
|
|
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']);
|
|
}
|
|
|
|
// Premium summery for show and hide the Additional premium data
|
|
if ($show_premium_columns) {
|
|
$premium = '₹ ' . format_indian_number(round($inner_item['rata_premimum']));
|
|
$gst_forself = '₹ ' . format_indian_number(round($inner_item['gst']));
|
|
}
|
|
|
|
$temp_data .= '<tr>';
|
|
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
|
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
|
|
if ($policy_premium_data['premium_type'] == 2) {
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
} else {
|
|
// $temp_data .= (($si != 0 && count($item) != 1) ? ('<td rowspan='.$rowspan.'>' . $si . '</td>') : ($si == 0 ? "" : '<td>' . $si . '</td>') );
|
|
|
|
if ($si != 0 && count($item) != 1 && $is_si_set == 0) {
|
|
|
|
$temp_data .= '<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $si . '</td>';
|
|
$is_si_set = 1;
|
|
} else {
|
|
|
|
if ($is_si_set == 1) {
|
|
$temp_data .= '';
|
|
} else {
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
}
|
|
}
|
|
}
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if (($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) && $show_premium_columns) {
|
|
$temp_data .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
}
|
|
|
|
$temp_data .= '</tr>';
|
|
|
|
$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';
|
|
}
|
|
|
|
$is_premium_summery = (int) ($client_policy_data['is_premium_summery'] ?? 0);
|
|
$show_premium_columns = ($is_premium_summery === 1);
|
|
$include_addon_summary = in_array($is_premium_summery, [1, 2], true);
|
|
|
|
$table_content .= $policy_name_for_policy_type . '</h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Add text-align: center to the table head
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th>Relation</th>';
|
|
$table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
$table_content .= '<th>Sum Insured</th>';
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if (($is_addon == 2 || $is_addon == 3) && $show_premium_columns) {
|
|
$table_content .= '<th>Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Add text-align: center to the table body
|
|
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
if (($is_addon == 2 || $is_addon == 3) && $include_addon_summary) {
|
|
if ($show_premium_columns) {
|
|
$show_full_premium_breakdown = true;
|
|
}
|
|
$addon_list_array = [
|
|
'policy_name' => $policy_name_for_policy_type,
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
$Addon_list[] = $addon_list_array;
|
|
}
|
|
|
|
$temp_data = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
}
|
|
|
|
// 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) {
|
|
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
$temp_data = '';
|
|
$is_addon = '';
|
|
$rowspan = count($payable_employee_array['emp_data']) ?? 2;
|
|
|
|
$self_si_amount = $payable_employee_array['si_amount'] ?? 0;
|
|
$self_premium = $payable_employee_array['self_premium'] ?? 0;
|
|
$self_gst = $payable_employee_array['self_gst'] ?? 0;
|
|
|
|
|
|
// 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) {
|
|
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
} 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);
|
|
|
|
$si = '';
|
|
$premium = '';
|
|
$gst_forself = '';
|
|
$is_premium_summery = (int) ($client_policy_data['is_premium_summery'] ?? 0);
|
|
// value 2: hide Premium/GST columns even for payable-by-employee rows
|
|
$show_premium_columns = ($is_premium_summery === 1)
|
|
|| ($inner_item['payable_employee'] == 1 && $is_premium_summery !== 2);
|
|
|
|
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 {
|
|
|
|
$premium = '₹ ' . format_indian_number(round($inner_item['rata_premimum']));
|
|
$gst_forself = '₹ ' . format_indian_number(round($inner_item['gst']));
|
|
}
|
|
|
|
$temp_data .= '<tr>';
|
|
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
|
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
|
|
// dd($si);
|
|
|
|
// Premium summery for show and hide the Additional premium data
|
|
if ($show_premium_columns) {
|
|
if ($policy_premium_data['premium_type'] == 2) {
|
|
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
$temp_data .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
} else {
|
|
|
|
if ($policy_premium_data['premium_type'] == 1) {
|
|
|
|
$temp_data .= (($si != 0 && count($item) != 1) ? ('<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $si . '</td>') : ($si == 0 ? "" : '<td>' . $si . '</td>'));
|
|
$temp_data .= (($premium != 0 && count($item) != 1) ? ('<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $premium . '</td>') : ($premium == 0 ? "" : '<td>' . $premium . '</td>'));
|
|
$temp_data .= (($gst_forself != 0 && count($item) != 1) ? ('<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $gst_forself . '</td>') : ($gst_forself == 0 ? "" : '<td>' . $gst_forself . '</td>'));
|
|
} else {
|
|
|
|
$temp_data .= (($si != 0 && count($item) != 1) ? ('<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $si . '</td>') : ($si == 0 ? "" : '<td>' . $si . '</td>'));
|
|
$temp_data .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
}
|
|
|
|
$self_si_amount = 0;
|
|
$self_premium = 0;
|
|
$self_gst = 0;
|
|
}
|
|
} else {
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
}
|
|
|
|
|
|
$temp_data .= '</tr>';
|
|
|
|
$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) {
|
|
$policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
|
|
}
|
|
|
|
$is_premium_summery = (int) ($client_policy_data['is_premium_summery'] ?? 0);
|
|
$show_premium_columns = ($is_premium_summery === 1)
|
|
|| ($inner_item['payable_employee'] == 1 && $is_premium_summery !== 2);
|
|
$include_addon_summary = ($inner_item['payable_employee'] == 1)
|
|
|| in_array($is_premium_summery, [1, 2], true);
|
|
|
|
$table_content .= $policy_name_for_policy_type . ' ( Payable By Employee ) </h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Add text-align: center to the table head
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th>Relation</th>';
|
|
$table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
$table_content .= '<th>Sum Insured</th>';
|
|
|
|
// Premium summery for show and hide the Additional premium data
|
|
if ($show_premium_columns) {
|
|
$table_content .= '<th>Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Add text-align: center to the table body
|
|
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
// Premium summery for show and hide the Additional premium data
|
|
if ($include_addon_summary) {
|
|
if ($is_premium_summery !== 2) {
|
|
$show_full_premium_breakdown = true;
|
|
}
|
|
$addon_list_array = [
|
|
'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
$Addon_list[] = $addon_list_array;
|
|
}
|
|
|
|
|
|
$temp_data = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
}
|
|
}
|
|
|
|
if (count($Addon_list) > 0) {
|
|
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Center align for table header and body
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Policy Name</th>';
|
|
if ($show_full_premium_breakdown) {
|
|
$table_content .= '<th>Additional Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
}
|
|
// is_premium_summery == 2: label as Total Premium
|
|
$total_label = $show_full_premium_breakdown ? 'Total' : 'Total Premium';
|
|
$table_content .= '<th>' . $total_label . '</th>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
|
|
$sum_total = 0;
|
|
foreach ($Addon_list as $key => $value) {
|
|
$total_addon = $value['gst'] + $value['addtional_premium'];
|
|
$sum_total += $total_addon;
|
|
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td>' . $value['policy_name'] . '</td>';
|
|
if ($show_full_premium_breakdown) {
|
|
$table_content .= '<td>₹' . format_indian_number($value['addtional_premium']) . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($value['gst']) . '</td>';
|
|
}
|
|
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr>';
|
|
}
|
|
|
|
$sum_total_words = numberToWords($sum_total);
|
|
$table_content .= '<tr>';
|
|
if ($show_full_premium_breakdown) {
|
|
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
|
|
} else {
|
|
$table_content .= '<td><b>' . $total_label . '</b></td>';
|
|
}
|
|
$table_content .= '<td>₹' . format_indian_number($sum_total) . '</td>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div></div>';
|
|
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
|
|
}
|
|
|
|
// 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_mobile]]", "{{member_mobile}}"], $employee_mobile_no, $mail_content);
|
|
$mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content, $mail_content);
|
|
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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 == '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();
|
|
$clientPolicyModel = new ClientPolicyModel();
|
|
$PolicyPremium1Model = new PolicyPremium1Model();
|
|
$PolicyPremium2Model = new PolicyPremium2Model();
|
|
|
|
|
|
$client_data = $clientModel->where('id', $client_id)->first();
|
|
|
|
$params['client_data'] = $client_data;
|
|
|
|
$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) {
|
|
$userModel = new UserModel();
|
|
$user_data = $userModel->where('id', $value['user_id'])->first();
|
|
$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(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
// Step 1: Replace the placeholder with an HTML table structure
|
|
$mail = '';
|
|
$table_content = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
$array_list = $params['array_list'];
|
|
$Addon_list = [];
|
|
|
|
foreach ($array_list as $item) {
|
|
|
|
$payable_employee_array = [];
|
|
|
|
if (count($item) != 0) {
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
$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) {
|
|
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
} 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) {
|
|
$payable_employee_array[] = $inner_item;
|
|
}
|
|
|
|
$policy_name = $inner_item['policy_name'];
|
|
|
|
if ($inner_item['relationship'] == 'Self') {
|
|
// $emp_code = ' (' . $inner_item['emp_code'] . ')';
|
|
$emp_code = ' ( Employee Code : ' . $inner_item['emp_code'] . ')';
|
|
} else {
|
|
$emp_code = '';
|
|
}
|
|
|
|
$si = '';
|
|
$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']));
|
|
// }
|
|
|
|
$temp_data .= '<tr>';
|
|
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
|
|
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
|
|
$temp_data .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
}
|
|
|
|
$temp_data .= '</tr>';
|
|
|
|
$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';
|
|
}
|
|
|
|
$table_content .= $policy_name_for_policy_type . '</h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Add text-align: center to the table head
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th>Relation</th>';
|
|
$table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
$table_content .= '<th>Sum Insured</th>';
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if ($is_addon == 2 || $is_addon == 3) {
|
|
$table_content .= '<th>Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Add text-align: center to the table body
|
|
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
if ($is_addon == 2 || $is_addon == 3) {
|
|
$addon_list_array = [
|
|
'policy_name' => $policy_name_for_policy_type,
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
$Addon_list[] = $addon_list_array;
|
|
}
|
|
|
|
$temp_data = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
}
|
|
|
|
if (count($payable_employee_array) > 0) {
|
|
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>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) {
|
|
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
} 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
|
|
|
|
|
|
$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 .= '<tr>';
|
|
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
|
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
$temp_data .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
|
|
$temp_data .= '</tr>';
|
|
|
|
$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) {
|
|
$policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
|
|
}
|
|
|
|
$table_content .= $policy_name_for_policy_type . ' ( Payable By Employee ) </h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Add text-align: center to the table head
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th>Relation</th>';
|
|
$table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
$table_content .= '<th>Sum Insured</th>';
|
|
$table_content .= '<th>Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Add text-align: center to the table body
|
|
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
|
|
$addon_list_array = [
|
|
'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
$Addon_list[] = $addon_list_array;
|
|
|
|
|
|
$temp_data = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
}
|
|
}
|
|
|
|
if (count($Addon_list) > 0) {
|
|
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Center align for table header and body
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Policy Name</th>';
|
|
$table_content .= '<th>Additional Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
$table_content .= '<th>Total</th>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
|
|
$sum_total = 0;
|
|
foreach ($Addon_list as $key => $value) {
|
|
$total_addon = $value['gst'] + $value['addtional_premium'];
|
|
$sum_total += $total_addon;
|
|
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td>' . $value['policy_name'] . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($value['addtional_premium']) . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($value['gst']) . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr>';
|
|
}
|
|
|
|
$sum_total_words = numberToWords($sum_total);
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
|
|
$table_content .= '<td>₹' . format_indian_number($sum_total) . '</td>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div></div>';
|
|
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
|
|
}
|
|
|
|
|
|
$mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content, $mail_content);
|
|
|
|
$account_manager_mail_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);
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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();
|
|
// $PolicyPremium2Model = new PolicyPremium2Model();
|
|
|
|
// $client_data =$clientModel->where('id', $client_id)->first();
|
|
// $notificationModel = new NotificationModel();
|
|
// $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
|
|
// $clientRMModel =new ClientRMModel();
|
|
|
|
// if (isset($notification_data['enabled']) && $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){
|
|
// $userModel = new UserModel();
|
|
// $user_data = $userModel->where('id', $value['user_id'])->first();
|
|
// $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}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
// $mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
// $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
|
|
// $mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
// // Step 1: Replace the placeholder with an HTML table structure
|
|
// $mail = '';
|
|
// $table_content = '';
|
|
// $addtional_premium = 0;
|
|
// $gst = 0;
|
|
// $array_list = $params['array_list'];
|
|
// $Addon_list = [];
|
|
|
|
// foreach ($array_list as $item) {
|
|
|
|
// $payable_employee_array = [];
|
|
|
|
// if (count($item) != 0) {
|
|
// $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
// $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 ){
|
|
// $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
// }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){
|
|
// $payable_employee_array[] = $inner_item;
|
|
// }
|
|
|
|
// $policy_name = $inner_item['policy_name'];
|
|
|
|
// if ($inner_item['relationship'] == 'Self') {
|
|
// $emp_code = ' (' . $inner_item['emp_code'] . ')';
|
|
// } else {
|
|
// $emp_code = '';
|
|
// }
|
|
|
|
// $si = '';
|
|
// $premium = '';
|
|
// $gst_forself = '';
|
|
|
|
// // dd($policy_premium_data, $client_policy_data, $inner_item);
|
|
|
|
// // 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']));
|
|
// // }
|
|
|
|
// $temp_data .= '<tr>';
|
|
// $temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
|
|
// $temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
// $temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
// $temp_data .= '<td>' . $si . '</td>';
|
|
|
|
// // Only Display SI Topup and Dependent Addon
|
|
// if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
|
|
// $temp_data .= '<td>' . $premium . '</td>';
|
|
// $temp_data .= '<td>' . $gst_forself . '</td>';
|
|
// }
|
|
|
|
// $temp_data .= '</tr>';
|
|
|
|
// $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';
|
|
// }
|
|
|
|
// $table_content .= $policy_name_for_policy_type . '</h4></div>';
|
|
// $table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// // Add text-align: center to the table head
|
|
// $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<th>Name</th>';
|
|
// $table_content .= '<th>Relation</th>';
|
|
// $table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
// $table_content .= '<th>Sum Insured</th>';
|
|
|
|
// // Only Display SI Topup and Dependent Addon
|
|
// if ($is_addon == 2 || $is_addon == 3) {
|
|
// $table_content .= '<th>Premium</th>';
|
|
// $table_content .= '<th>GST</th>';
|
|
// }
|
|
|
|
// $table_content .= '</tr>';
|
|
// $table_content .= '</thead>';
|
|
|
|
// // Add text-align: center to the table body
|
|
// $table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
// $table_content .= '</table></div>';
|
|
|
|
// if ($is_addon == 2 || $is_addon == 3) {
|
|
// $addon_list_array = [
|
|
// 'policy_name' => $policy_name_for_policy_type,
|
|
// 'addtional_premium' => round($addtional_premium),
|
|
// 'gst' => round($gst)
|
|
// ];
|
|
// $Addon_list[] = $addon_list_array;
|
|
// }
|
|
|
|
// $temp_data = '';
|
|
// $addtional_premium = 0;
|
|
// $gst = 0;
|
|
// }
|
|
|
|
// if(count($payable_employee_array) > 0){
|
|
|
|
// $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>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 ){
|
|
// $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
// }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
|
|
|
|
|
|
// $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 .= '<tr>';
|
|
// $temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
|
// $temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
// $temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
// $temp_data .= '<td>' . $si . '</td>';
|
|
// $temp_data .= '<td>' . $premium . '</td>';
|
|
// $temp_data .= '<td>' . $gst_forself . '</td>';
|
|
|
|
// $temp_data .= '</tr>';
|
|
|
|
// $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){
|
|
// $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
|
|
// }
|
|
|
|
// $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee ) </h4></div>';
|
|
// $table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// // Add text-align: center to the table head
|
|
// $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<th>Name</th>';
|
|
// $table_content .= '<th>Relation</th>';
|
|
// $table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
// $table_content .= '<th>Sum Insured</th>';
|
|
// $table_content .= '<th>Premium</th>';
|
|
// $table_content .= '<th>GST</th>';
|
|
|
|
// $table_content .= '</tr>';
|
|
// $table_content .= '</thead>';
|
|
|
|
// // Add text-align: center to the table body
|
|
// $table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
// $table_content .= '</table></div>';
|
|
|
|
|
|
// $addon_list_array = [
|
|
// 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
|
|
// 'addtional_premium' => round($addtional_premium),
|
|
// 'gst' => round($gst)
|
|
// ];
|
|
// $Addon_list[] = $addon_list_array;
|
|
|
|
|
|
// $temp_data = '';
|
|
// $addtional_premium = 0;
|
|
// $gst = 0;
|
|
|
|
// }
|
|
// }
|
|
|
|
// if (count($Addon_list) > 0) {
|
|
// $table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
|
|
// $table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// // Center align for table header and body
|
|
// $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<th>Policy Name</th>';
|
|
// $table_content .= '<th>Additional Premium</th>';
|
|
// $table_content .= '<th>GST</th>';
|
|
// $table_content .= '<th>Total</th>';
|
|
// $table_content .= '</tr>';
|
|
// $table_content .= '</thead>';
|
|
|
|
// $table_content .= '<tbody style="text-align: center;">';
|
|
|
|
// $sum_total = 0;
|
|
// foreach ($Addon_list as $key => $value) {
|
|
// $total_addon = $value['gst'] + $value['addtional_premium'];
|
|
// $sum_total += $total_addon;
|
|
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<td>' . $value['policy_name'] . '</td>';
|
|
// $table_content .= '<td>₹' . format_indian_number($value['addtional_premium']) . '</td>';
|
|
// $table_content .= '<td>₹' . format_indian_number($value['gst']) . '</td>';
|
|
// $table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
|
|
// $table_content .= '</tr>';
|
|
// }
|
|
|
|
// $sum_total_words = numberToWords($sum_total);
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<td></td><td></td><td><b>Total</b></td>';
|
|
// $table_content .= '<td>₹' . format_indian_number($sum_total) . '</td>';
|
|
// $table_content .= '</tr>';
|
|
// $table_content .= '</tbody>';
|
|
// $table_content .= '</table></div></div>';
|
|
// // $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
|
|
// }
|
|
|
|
// $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content);
|
|
|
|
|
|
// $hr_mails = $client_data['hr_mails'];
|
|
// $mail_array = explode(',', $hr_mails);
|
|
// $mail_array = array_map('trim', $mail_array);
|
|
// $wholeData = [];
|
|
// foreach ($mail_array as $key => $value) {
|
|
//
|
|
//
|
|
// $mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
// $data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
// $data['mail_content'] = $mail_content;
|
|
// $mail_content = view('mail_template',$data);
|
|
// $mail_content = $header_of_mail .
|
|
// '<div align="center">
|
|
// <table width="100%" border="0" cellspacing="0" cellpadding="0"
|
|
// style="max-width:600px;">
|
|
|
|
// <tr>
|
|
// <td align="left" style="padding:15px; word-break:break-word; font-family:arial, sans-serif; font-size:14px; line-height:20px;">
|
|
// ' . $mail_content . '
|
|
// </td>
|
|
// </tr>
|
|
// </table>
|
|
// </div>' . $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'}};
|
|
// }
|
|
|
|
// return $wholeData;
|
|
// }
|
|
|
|
// }
|
|
}
|
|
|
|
public static function sendMailNotification_old($action, $params)
|
|
{
|
|
$wholeData = [];
|
|
|
|
if ($action == 'member_welcome_mail') {
|
|
|
|
$dataToInsert = $params['dataToInsert'];
|
|
$notification = $params['notification'];
|
|
$client_data = $params['client_data'];
|
|
$common = $params['common'];
|
|
|
|
$mailAttachmentModel = new MailAttachmentModel();
|
|
$attachment_data = $mailAttachmentModel
|
|
->select('file_path, file_name')
|
|
->where('notification_id', $notification['id'])
|
|
->where('is_active', 1)
|
|
->findAll();
|
|
|
|
$attachments = [];
|
|
foreach ($attachment_data as $data) {
|
|
$attachments[] = [
|
|
"filePath" => WRITEPATH . $data['file_path'],
|
|
"fileName" => $data['file_name']
|
|
];
|
|
}
|
|
|
|
$mail = $dataToInsert['email_corporate'];
|
|
$subject = $notification['subject'];
|
|
$app_link = $_ENV['App_Url'];
|
|
$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'];
|
|
|
|
$enrollment_open_date = !empty($params['enrollment_open_date'] ?? null)
|
|
? change_date_format($params['enrollment_open_date'], 'Y-m-d', 'F d, Y')
|
|
: 'N/A';
|
|
|
|
$enrollment_close_date = !empty($params['enrollment_close_date'] ?? null)
|
|
? change_date_format($params['enrollment_close_date'], 'Y-m-d', 'F d, Y')
|
|
: 'N/A';
|
|
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$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_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
|
|
$mail_content = str_replace(["[[enrollment_open_date]]", "{{enrollment_open_date}}"], $enrollment_open_date, $mail_content);
|
|
$mail_content = str_replace(["[[enrollment_close_date]]", "{{enrollment_close_date}}"], $enrollment_close_date, $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') {
|
|
|
|
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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'];
|
|
$notification_data = $params['notification_data'];
|
|
$client_data = $params['client_data'];
|
|
$common = $params['common'];
|
|
|
|
$mailAttachmentModel = new MailAttachmentModel();
|
|
$attachment_data = $mailAttachmentModel
|
|
->select('file_path, file_name')
|
|
->where('notification_id', $notification_data['id'])
|
|
->where('is_active', 1)
|
|
->findAll()??[];
|
|
|
|
$attachments = [];
|
|
foreach ($attachment_data as $data) {
|
|
$attachments[] = [
|
|
"filePath" => WRITEPATH . $data['file_path'],
|
|
"fileName" => $data['file_name']
|
|
];
|
|
}
|
|
|
|
$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}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
$mail_content = str_replace(["[[policy_no]]", "{{policy_no}}"], $emp_data['policy_no'] ?? '', $mail_content);
|
|
$mail_content = str_replace(["[[emp_code]]", "{{emp_code}}"], $emp_data['emp_code'] ?? '', $mail_content);
|
|
$mail_content = str_replace(["[[employee_name]]", "{{employee_name}}"], $emp_data['name'] ?? '', $mail_content);
|
|
$mail_content = str_replace(["[[employee_mobile]]", "{{employee_mobile}}"], $emp_data['mobile'] ?? '', $mail_content);
|
|
//convert to dd-mm-yyyy format
|
|
$emp_data['enrollment_open_date'] = date('d-m-Y', strtotime($emp_data['enrollment_open_date']));
|
|
$emp_data['enrollment_close_date'] = date('d-m-Y', strtotime($emp_data['enrollment_close_date']));
|
|
$mail_content = str_replace(["[[enrollment_open_date]]", "{{enrollment_open_date}}"], $emp_data['enrollment_open_date'] ?? '', $mail_content);
|
|
$mail_content = str_replace(["[[enrollment_close_date]]", "{{enrollment_close_date}}"], $emp_data['enrollment_close_date'] ?? '', $mail_content);
|
|
|
|
|
|
|
|
$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_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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'], 'common' => $common];
|
|
|
|
return $wholeData;
|
|
} else if ($action == 'member_ecard_mail') {
|
|
|
|
$notification = $params['notification'];
|
|
$get_emp_email_and_other_details = $params['get_emp_email_and_other_details'];
|
|
$rand_string = $params['rand_string'];
|
|
$client_data = $params['client_data'];
|
|
$tpa_id = $params['tpa_id'];
|
|
$common = $params['common'];
|
|
|
|
|
|
$mail_content = $notification['mail_content'];
|
|
$mail = $get_emp_email_and_other_details['email_corporate'];
|
|
$subject = $notification['subject'];
|
|
|
|
$cleanedText = mb_convert_encoding($subject, 'UTF-8', 'UTF-8'); // Normalize encoding
|
|
$cleanedText = preg_replace('/[^\x20-\x7E]/', '', $cleanedText);
|
|
|
|
$subject = $cleanedText;
|
|
|
|
$link = generate_download_link($rand_string) . '/1';
|
|
|
|
$app_link = $_ENV['App_Url'];
|
|
$name = $get_emp_email_and_other_details['name'];
|
|
$employee_mobile_no = $get_emp_email_and_other_details['mobile'];
|
|
$mail_content = $notification['mail_content'];
|
|
|
|
$nhance_logo = $_ENV['NHANCE_LOGO'];
|
|
// 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}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
|
|
$mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name, $mail_content);
|
|
$mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $employee_mobile_no, $mail_content);
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
$mail_content = str_replace(["[[post_enrollment_app_link]]", "{{post_enrollment_app_link}}"], "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content);
|
|
// $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content);
|
|
$mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "<a href='$link/1'>Download Insurance Card</a>", $mail_content);
|
|
$mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
|
|
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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') {
|
|
|
|
$array_list = $params['array_list']; //employeee lst
|
|
$client_policy_id = $params['client_policy_id'];
|
|
$emp_code = $params['emp_code'];
|
|
$client_id = $params['client_id'];
|
|
$common = $params['common'];
|
|
|
|
$clientModel = new ClientModel();
|
|
$notificationModel = new NotificationModel();
|
|
$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();
|
|
|
|
$params['client_data'] = $client_data;
|
|
// dd($notification_data);
|
|
|
|
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'];
|
|
// $client_logo = $nhance_logo;
|
|
|
|
$mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
// Step 1: Replace the placeholder with an HTML table structure
|
|
$mail = '';
|
|
$table_content = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
$Addon_list = [];
|
|
$name = '';
|
|
$employee_mobile_no = '';
|
|
$emp_code = '';
|
|
|
|
// echo '<pre>';
|
|
// dd($array_list); die;
|
|
|
|
|
|
|
|
foreach ($array_list as $item) {
|
|
|
|
$payable_employee_array = [];
|
|
|
|
if (count($item) != 0) {
|
|
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
$temp_data = '';
|
|
$policy_name = '';
|
|
$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) {
|
|
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
} 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) {
|
|
$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'] . ')';
|
|
$emp_code = ' ( Employee 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 ($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']);
|
|
}
|
|
|
|
// 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']));
|
|
}
|
|
|
|
$temp_data .= '<tr>';
|
|
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
|
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
|
|
if ($policy_premium_data['premium_type'] == 2) {
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
} else {
|
|
// $temp_data .= (($si != 0 && count($item) != 1) ? ('<td rowspan='.$rowspan.'>' . $si . '</td>') : ($si == 0 ? "" : '<td>' . $si . '</td>') );
|
|
|
|
if ($si != 0 && count($item) != 1 && $is_si_set == 0) {
|
|
|
|
$temp_data .= '<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $si . '</td>';
|
|
$is_si_set = 1;
|
|
} else {
|
|
|
|
if ($is_si_set == 1) {
|
|
$temp_data .= '';
|
|
} else {
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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 .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
}
|
|
|
|
$temp_data .= '</tr>';
|
|
|
|
$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';
|
|
}
|
|
|
|
$table_content .= $policy_name_for_policy_type . '</h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Add text-align: center to the table head
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th>Relation</th>';
|
|
$table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
$table_content .= '<th>Sum Insured</th>';
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if (($is_addon == 2 || $is_addon == 3) && $client_policy_data['is_premium_summery'] == 1) {
|
|
$table_content .= '<th>Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Add text-align: center to the table body
|
|
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
if (($is_addon == 2 || $is_addon == 3) && $client_policy_data['is_premium_summery'] == 1) {
|
|
$addon_list_array = [
|
|
'policy_name' => $policy_name_for_policy_type,
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
$Addon_list[] = $addon_list_array;
|
|
}
|
|
|
|
$temp_data = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
}
|
|
|
|
// 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) {
|
|
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
$temp_data = '';
|
|
$is_addon = '';
|
|
$rowspan = count($payable_employee_array['emp_data']) ?? 2;
|
|
|
|
$self_si_amount = $payable_employee_array['si_amount'] ?? 0;
|
|
$self_premium = $payable_employee_array['self_premium'] ?? 0;
|
|
$self_gst = $payable_employee_array['self_gst'] ?? 0;
|
|
|
|
|
|
// 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) {
|
|
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
} 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);
|
|
|
|
$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'] == 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 {
|
|
|
|
$premium = '₹ ' . format_indian_number(round($inner_item['rata_premimum']));
|
|
$gst_forself = '₹ ' . format_indian_number(round($inner_item['gst']));
|
|
}
|
|
|
|
$temp_data .= '<tr>';
|
|
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
|
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
|
|
// 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) {
|
|
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
$temp_data .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
} else {
|
|
|
|
if ($policy_premium_data['premium_type'] == 1) {
|
|
|
|
$temp_data .= (($si != 0 && count($item) != 1) ? ('<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $si . '</td>') : ($si == 0 ? "" : '<td>' . $si . '</td>'));
|
|
$temp_data .= (($premium != 0 && count($item) != 1) ? ('<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $premium . '</td>') : ($premium == 0 ? "" : '<td>' . $premium . '</td>'));
|
|
$temp_data .= (($gst_forself != 0 && count($item) != 1) ? ('<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $gst_forself . '</td>') : ($gst_forself == 0 ? "" : '<td>' . $gst_forself . '</td>'));
|
|
} else {
|
|
|
|
$temp_data .= (($si != 0 && count($item) != 1) ? ('<td style="vertical-align: middle !important;" rowspan=' . $rowspan . '>' . $si . '</td>') : ($si == 0 ? "" : '<td>' . $si . '</td>'));
|
|
$temp_data .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
}
|
|
|
|
$self_si_amount = 0;
|
|
$self_premium = 0;
|
|
$self_gst = 0;
|
|
}
|
|
} else {
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
}
|
|
|
|
|
|
$temp_data .= '</tr>';
|
|
|
|
$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) {
|
|
$policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
|
|
}
|
|
|
|
$table_content .= $policy_name_for_policy_type . ' ( Payable By Employee ) </h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Add text-align: center to the table head
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th>Relation</th>';
|
|
$table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
$table_content .= '<th>Sum Insured</th>';
|
|
|
|
// Premium summery for show and hide the Additional premium data
|
|
if ($inner_item['payable_employee'] == 1 || $client_policy_data['is_premium_summery'] == 1) {
|
|
$table_content .= '<th>Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Add text-align: center to the table body
|
|
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
// Premium summery for show and hide the Additional premium data
|
|
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),
|
|
'gst' => round($gst)
|
|
];
|
|
$Addon_list[] = $addon_list_array;
|
|
}
|
|
|
|
|
|
$temp_data = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
}
|
|
}
|
|
|
|
if (count($Addon_list) > 0) {
|
|
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Center align for table header and body
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Policy Name</th>';
|
|
$table_content .= '<th>Additional Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
$table_content .= '<th>Total</th>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
|
|
$sum_total = 0;
|
|
foreach ($Addon_list as $key => $value) {
|
|
$total_addon = $value['gst'] + $value['addtional_premium'];
|
|
$sum_total += $total_addon;
|
|
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td>' . $value['policy_name'] . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($value['addtional_premium']) . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($value['gst']) . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr>';
|
|
}
|
|
|
|
$sum_total_words = numberToWords($sum_total);
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
|
|
$table_content .= '<td>₹' . format_indian_number($sum_total) . '</td>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div></div>';
|
|
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
|
|
}
|
|
|
|
// 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_mobile]]", "{{member_mobile}}"], $employee_mobile_no, $mail_content);
|
|
$mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content, $mail_content);
|
|
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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 == '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();
|
|
$clientPolicyModel = new ClientPolicyModel();
|
|
$PolicyPremium1Model = new PolicyPremium1Model();
|
|
$PolicyPremium2Model = new PolicyPremium2Model();
|
|
|
|
|
|
$client_data = $clientModel->where('id', $client_id)->first();
|
|
|
|
$params['client_data'] = $client_data;
|
|
|
|
$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) {
|
|
$userModel = new UserModel();
|
|
$user_data = $userModel->where('id', $value['user_id'])->first();
|
|
$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(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
// Step 1: Replace the placeholder with an HTML table structure
|
|
$mail = '';
|
|
$table_content = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
$array_list = $params['array_list'];
|
|
$Addon_list = [];
|
|
|
|
foreach ($array_list as $item) {
|
|
|
|
$payable_employee_array = [];
|
|
|
|
if (count($item) != 0) {
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
$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) {
|
|
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
} 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) {
|
|
$payable_employee_array[] = $inner_item;
|
|
}
|
|
|
|
$policy_name = $inner_item['policy_name'];
|
|
|
|
if ($inner_item['relationship'] == 'Self') {
|
|
// $emp_code = ' (' . $inner_item['emp_code'] . ')';
|
|
$emp_code = ' ( Employee Code : ' . $inner_item['emp_code'] . ')';
|
|
} else {
|
|
$emp_code = '';
|
|
}
|
|
|
|
$si = '';
|
|
$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']));
|
|
// }
|
|
|
|
$temp_data .= '<tr>';
|
|
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
|
|
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
|
|
$temp_data .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
}
|
|
|
|
$temp_data .= '</tr>';
|
|
|
|
$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';
|
|
}
|
|
|
|
$table_content .= $policy_name_for_policy_type . '</h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Add text-align: center to the table head
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th>Relation</th>';
|
|
$table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
$table_content .= '<th>Sum Insured</th>';
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if ($is_addon == 2 || $is_addon == 3) {
|
|
$table_content .= '<th>Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Add text-align: center to the table body
|
|
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
if ($is_addon == 2 || $is_addon == 3) {
|
|
$addon_list_array = [
|
|
'policy_name' => $policy_name_for_policy_type,
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
$Addon_list[] = $addon_list_array;
|
|
}
|
|
|
|
$temp_data = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
}
|
|
|
|
if (count($payable_employee_array) > 0) {
|
|
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>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) {
|
|
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
} 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
|
|
|
|
|
|
$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 .= '<tr>';
|
|
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
|
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
$temp_data .= '<td>' . $si . '</td>';
|
|
$temp_data .= '<td>' . $premium . '</td>';
|
|
$temp_data .= '<td>' . $gst_forself . '</td>';
|
|
|
|
$temp_data .= '</tr>';
|
|
|
|
$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) {
|
|
$policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
|
|
}
|
|
|
|
$table_content .= $policy_name_for_policy_type . ' ( Payable By Employee ) </h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Add text-align: center to the table head
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th>Relation</th>';
|
|
$table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
$table_content .= '<th>Sum Insured</th>';
|
|
$table_content .= '<th>Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Add text-align: center to the table body
|
|
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
|
|
$addon_list_array = [
|
|
'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
$Addon_list[] = $addon_list_array;
|
|
|
|
|
|
$temp_data = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
}
|
|
}
|
|
|
|
if (count($Addon_list) > 0) {
|
|
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// Center align for table header and body
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Policy Name</th>';
|
|
$table_content .= '<th>Additional Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
$table_content .= '<th>Total</th>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
|
|
$sum_total = 0;
|
|
foreach ($Addon_list as $key => $value) {
|
|
$total_addon = $value['gst'] + $value['addtional_premium'];
|
|
$sum_total += $total_addon;
|
|
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td>' . $value['policy_name'] . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($value['addtional_premium']) . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($value['gst']) . '</td>';
|
|
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr>';
|
|
}
|
|
|
|
$sum_total_words = numberToWords($sum_total);
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
|
|
$table_content .= '<td>₹' . format_indian_number($sum_total) . '</td>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div></div>';
|
|
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
|
|
}
|
|
|
|
|
|
$mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content, $mail_content);
|
|
|
|
$account_manager_mail_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);
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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();
|
|
// $PolicyPremium2Model = new PolicyPremium2Model();
|
|
|
|
// $client_data =$clientModel->where('id', $client_id)->first();
|
|
// $notificationModel = new NotificationModel();
|
|
// $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
|
|
// $clientRMModel =new ClientRMModel();
|
|
|
|
// if (isset($notification_data['enabled']) && $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){
|
|
// $userModel = new UserModel();
|
|
// $user_data = $userModel->where('id', $value['user_id'])->first();
|
|
// $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}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
// $mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
// $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
|
|
// $mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
// // Step 1: Replace the placeholder with an HTML table structure
|
|
// $mail = '';
|
|
// $table_content = '';
|
|
// $addtional_premium = 0;
|
|
// $gst = 0;
|
|
// $array_list = $params['array_list'];
|
|
// $Addon_list = [];
|
|
|
|
// foreach ($array_list as $item) {
|
|
|
|
// $payable_employee_array = [];
|
|
|
|
// if (count($item) != 0) {
|
|
// $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
// $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 ){
|
|
// $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
// }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){
|
|
// $payable_employee_array[] = $inner_item;
|
|
// }
|
|
|
|
// $policy_name = $inner_item['policy_name'];
|
|
|
|
// if ($inner_item['relationship'] == 'Self') {
|
|
// $emp_code = ' (' . $inner_item['emp_code'] . ')';
|
|
// } else {
|
|
// $emp_code = '';
|
|
// }
|
|
|
|
// $si = '';
|
|
// $premium = '';
|
|
// $gst_forself = '';
|
|
|
|
// // dd($policy_premium_data, $client_policy_data, $inner_item);
|
|
|
|
// // 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']));
|
|
// // }
|
|
|
|
// $temp_data .= '<tr>';
|
|
// $temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
|
|
// $temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
// $temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
// $temp_data .= '<td>' . $si . '</td>';
|
|
|
|
// // Only Display SI Topup and Dependent Addon
|
|
// if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
|
|
// $temp_data .= '<td>' . $premium . '</td>';
|
|
// $temp_data .= '<td>' . $gst_forself . '</td>';
|
|
// }
|
|
|
|
// $temp_data .= '</tr>';
|
|
|
|
// $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';
|
|
// }
|
|
|
|
// $table_content .= $policy_name_for_policy_type . '</h4></div>';
|
|
// $table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// // Add text-align: center to the table head
|
|
// $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<th>Name</th>';
|
|
// $table_content .= '<th>Relation</th>';
|
|
// $table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
// $table_content .= '<th>Sum Insured</th>';
|
|
|
|
// // Only Display SI Topup and Dependent Addon
|
|
// if ($is_addon == 2 || $is_addon == 3) {
|
|
// $table_content .= '<th>Premium</th>';
|
|
// $table_content .= '<th>GST</th>';
|
|
// }
|
|
|
|
// $table_content .= '</tr>';
|
|
// $table_content .= '</thead>';
|
|
|
|
// // Add text-align: center to the table body
|
|
// $table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
// $table_content .= '</table></div>';
|
|
|
|
// if ($is_addon == 2 || $is_addon == 3) {
|
|
// $addon_list_array = [
|
|
// 'policy_name' => $policy_name_for_policy_type,
|
|
// 'addtional_premium' => round($addtional_premium),
|
|
// 'gst' => round($gst)
|
|
// ];
|
|
// $Addon_list[] = $addon_list_array;
|
|
// }
|
|
|
|
// $temp_data = '';
|
|
// $addtional_premium = 0;
|
|
// $gst = 0;
|
|
// }
|
|
|
|
// if(count($payable_employee_array) > 0){
|
|
|
|
// $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>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 ){
|
|
// $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
|
|
// }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
|
|
|
|
|
|
// $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 .= '<tr>';
|
|
// $temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
|
// $temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
|
// $temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
|
// $temp_data .= '<td>' . $si . '</td>';
|
|
// $temp_data .= '<td>' . $premium . '</td>';
|
|
// $temp_data .= '<td>' . $gst_forself . '</td>';
|
|
|
|
// $temp_data .= '</tr>';
|
|
|
|
// $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){
|
|
// $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
|
|
// }
|
|
|
|
// $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee ) </h4></div>';
|
|
// $table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// // Add text-align: center to the table head
|
|
// $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<th>Name</th>';
|
|
// $table_content .= '<th>Relation</th>';
|
|
// $table_content .= '<th style="width:15%">Date Of Birth</th>';
|
|
// $table_content .= '<th>Sum Insured</th>';
|
|
// $table_content .= '<th>Premium</th>';
|
|
// $table_content .= '<th>GST</th>';
|
|
|
|
// $table_content .= '</tr>';
|
|
// $table_content .= '</thead>';
|
|
|
|
// // Add text-align: center to the table body
|
|
// $table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
|
|
// $table_content .= '</table></div>';
|
|
|
|
|
|
// $addon_list_array = [
|
|
// 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
|
|
// 'addtional_premium' => round($addtional_premium),
|
|
// 'gst' => round($gst)
|
|
// ];
|
|
// $Addon_list[] = $addon_list_array;
|
|
|
|
|
|
// $temp_data = '';
|
|
// $addtional_premium = 0;
|
|
// $gst = 0;
|
|
|
|
// }
|
|
// }
|
|
|
|
// if (count($Addon_list) > 0) {
|
|
// $table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
|
|
// $table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
// // Center align for table header and body
|
|
// $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<th>Policy Name</th>';
|
|
// $table_content .= '<th>Additional Premium</th>';
|
|
// $table_content .= '<th>GST</th>';
|
|
// $table_content .= '<th>Total</th>';
|
|
// $table_content .= '</tr>';
|
|
// $table_content .= '</thead>';
|
|
|
|
// $table_content .= '<tbody style="text-align: center;">';
|
|
|
|
// $sum_total = 0;
|
|
// foreach ($Addon_list as $key => $value) {
|
|
// $total_addon = $value['gst'] + $value['addtional_premium'];
|
|
// $sum_total += $total_addon;
|
|
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<td>' . $value['policy_name'] . '</td>';
|
|
// $table_content .= '<td>₹' . format_indian_number($value['addtional_premium']) . '</td>';
|
|
// $table_content .= '<td>₹' . format_indian_number($value['gst']) . '</td>';
|
|
// $table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
|
|
// $table_content .= '</tr>';
|
|
// }
|
|
|
|
// $sum_total_words = numberToWords($sum_total);
|
|
// $table_content .= '<tr>';
|
|
// $table_content .= '<td></td><td></td><td><b>Total</b></td>';
|
|
// $table_content .= '<td>₹' . format_indian_number($sum_total) . '</td>';
|
|
// $table_content .= '</tr>';
|
|
// $table_content .= '</tbody>';
|
|
// $table_content .= '</table></div></div>';
|
|
// // $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
|
|
// }
|
|
|
|
// $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content);
|
|
|
|
|
|
// $hr_mails = $client_data['hr_mails'];
|
|
// $mail_array = explode(',', $hr_mails);
|
|
// $mail_array = array_map('trim', $mail_array);
|
|
// $wholeData = [];
|
|
// foreach ($mail_array as $key => $value) {
|
|
//
|
|
//
|
|
// $mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
// $data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
// $data['mail_content'] = $mail_content;
|
|
// $mail_content = view('mail_template',$data);
|
|
// $mail_content = $header_of_mail .
|
|
// '<div align="center">
|
|
// <table width="100%" border="0" cellspacing="0" cellpadding="0"
|
|
// style="max-width:600px;">
|
|
|
|
// <tr>
|
|
// <td align="left" style="padding:15px; word-break:break-word; font-family:arial, sans-serif; font-size:14px; line-height:20px;">
|
|
// ' . $mail_content . '
|
|
// </td>
|
|
// </tr>
|
|
// </table>
|
|
// </div>' . $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'}};
|
|
// }
|
|
|
|
// return $wholeData;
|
|
// }
|
|
|
|
// }
|
|
}
|
|
|
|
public static function sendMailNotificationForTesting($action, $params)
|
|
{
|
|
$wholeData = [];
|
|
|
|
if ($action == 'member_welcome_mail') {
|
|
|
|
$clientModel = new ClientModel();
|
|
|
|
$notification = $params['notification_data'];
|
|
$client_data = $params['client_data'];
|
|
$mail = $params['test_mail'];
|
|
|
|
$mail_content = $notification['mail_content'];
|
|
$subject = $notification['subject'];
|
|
|
|
$mailAttachmentModel = new MailAttachmentModel();
|
|
$attachment_data = $mailAttachmentModel
|
|
->select('file_path, file_name')
|
|
->where('notification_id', $notification['id'])
|
|
->where('is_active', 1)
|
|
->findAll();
|
|
|
|
$attachments = [];
|
|
foreach ($attachment_data as $data) {
|
|
$attachments[] = [
|
|
"filePath" => WRITEPATH . $data['file_path'],
|
|
"fileName" => $data['file_name']
|
|
];
|
|
}
|
|
|
|
// print_r($attachments); die;
|
|
|
|
$employee_name = 'John Doe';
|
|
$mobile = 9080706050;
|
|
|
|
$app_link = $_ENV['App_Url'];
|
|
$nhance_logo = $_ENV['NHANCE_LOGO'];
|
|
$enrollment_open_date = !empty($params['enrollment_open_date'] ?? null)
|
|
? date('F d, Y', strtotime(str_replace('/', '-', $params['enrollment_open_date'] ?? '')))
|
|
: date('F d, Y');
|
|
|
|
$enrollment_close_date = !empty($params['enrollment_close_date'] ?? null)
|
|
? date('F d, Y', strtotime(str_replace('/', '-', $params['enrollment_close_date'] ?? '')))
|
|
: date('F d, Y', strtotime('+15 days'));
|
|
|
|
$client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
|
|
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $employee_name, $mail_content);
|
|
$mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $mobile, $mail_content);
|
|
$mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
|
|
$mail_content = str_replace(["[[enrollment_open_date]]", "{{enrollment_open_date}}"], $enrollment_open_date, $mail_content);
|
|
$mail_content = str_replace(["[[enrollment_close_date]]", "{{enrollment_close_date}}"], $enrollment_close_date, $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
if ($mail != null || $mail != '') {
|
|
|
|
//
|
|
//
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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'];
|
|
|
|
$mailAttachmentModel = new MailAttachmentModel();
|
|
$attachment_data = $mailAttachmentModel
|
|
->select('file_path, file_name')
|
|
->where('notification_id', $notification_data['id'])
|
|
->where('is_active', 1)
|
|
->findAll()??[];
|
|
|
|
$attachments = [];
|
|
foreach ($attachment_data as $data) {
|
|
$attachments[] = [
|
|
"filePath" => WRITEPATH . $data['file_path'],
|
|
"fileName" => $data['file_name']
|
|
];
|
|
}
|
|
|
|
|
|
|
|
$mail_content = $notification_data['mail_content'];
|
|
$subject = $notification_data['subject'];
|
|
|
|
$nhance_logo = $_ENV['NHANCE_LOGO'];
|
|
$app_link = $_ENV['App_Url'];
|
|
|
|
$employee_name = 'John Doe';
|
|
$mobile = 9080706050;
|
|
|
|
$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}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
$mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $employee_name, $mail_content);
|
|
$mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $mobile, $mail_content);
|
|
|
|
if ((isset($notification_data) && $notification_data['enabled'] == 1)) {
|
|
|
|
if (isset($mail) && !empty($mail)) {
|
|
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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_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();
|
|
|
|
$attachments = [];
|
|
foreach ($attachment_data as $data) {
|
|
$attachments[] = [
|
|
"filePath" => WRITEPATH . $data['file_path'],
|
|
"fileName" => $data['file_name']
|
|
];
|
|
}
|
|
|
|
$mail_content = $notification['mail_content'];
|
|
$subject = $notification['subject'];
|
|
|
|
$rand_string = 'HX3kUh';
|
|
$link = generate_download_link($rand_string);
|
|
|
|
$name = 'John Doe';
|
|
$mobile = 9080706050;
|
|
|
|
$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}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
|
|
$mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name, $mail_content);
|
|
$mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $mobile, $mail_content);
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
$mail_content = str_replace(["[[post_enrollment_app_link]]", "{{post_enrollment_app_link}}"], "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content);
|
|
$mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "<a href='$link/1'>Download Insurance Card</a>", $mail_content);
|
|
$mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
|
|
|
|
|
|
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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') {
|
|
|
|
$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
|
|
];
|
|
|
|
|
|
$notification_data = $params['notification_data'];
|
|
$client_data = $params['client_data'];
|
|
$mail = $params['test_mail'];
|
|
|
|
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);
|
|
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
// Step 1: Replace the placeholder with an HTML table structure
|
|
$table_content = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
$Addon_list = [];
|
|
$name = $array_list['name'];
|
|
$mobile = $array_list['mobile'];
|
|
$emp_code = '';
|
|
|
|
$clientPolicyModel = new ClientPolicyModel();
|
|
$sample_policy = $clientPolicyModel
|
|
->where('client_id', $client_data['id'] ?? 0)
|
|
->where('is_active', 1)
|
|
->first();
|
|
$is_premium_summery = (int) ($sample_policy['is_premium_summery'] ?? 1);
|
|
$show_premium_columns = ($is_premium_summery === 1);
|
|
$include_addon_summary = in_array($is_premium_summery, [1, 2], true);
|
|
$show_full_premium_breakdown = ($is_premium_summery === 1);
|
|
|
|
if (!empty($array_list)) {
|
|
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
|
|
$policy_name = $array_list['policy_name'];
|
|
|
|
if ($array_list['relationship'] == 'Self') {
|
|
// $emp_code = ' (' . $array_list['emp_code'] . ')';
|
|
$emp_code = ' ( Employee Code : ' . $array_list['emp_code'] . ')';
|
|
} else {
|
|
$emp_code = '';
|
|
}
|
|
|
|
// Start table row
|
|
$table_content .= $policy_name . '</h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Relation</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Date Of Birth</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Sum Insured</th>';
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if (($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) && $show_premium_columns) {
|
|
$table_content .= '<th>Premium</th>';
|
|
$table_content .= '<th>GST</th>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Table body with details
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td>' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $array_list['relationship'] . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($array_list['basic_cover_si']) . '</td>';
|
|
|
|
if (($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) && $show_premium_columns) {
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['premium'])) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['gst'])) . '</td>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
// Calculate additional premium and GST if applicable
|
|
if (($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) && $include_addon_summary) {
|
|
$addtional_premium = $array_list['rata_premimum'];
|
|
$gst = $array_list['gst'];
|
|
|
|
// Prepare addon summary
|
|
$addon_list_array = [
|
|
'policy_name' => $policy_name,
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
|
|
$Addon_list[] = $addon_list_array;
|
|
}
|
|
|
|
// Generate summary table for addon if applicable
|
|
if (count($Addon_list) > 0) {
|
|
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Policy Name</th>';
|
|
if ($show_full_premium_breakdown) {
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Additional Premium</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
|
|
}
|
|
// is_premium_summery == 2: label as Total Premium
|
|
$total_label = $show_full_premium_breakdown ? 'Total' : 'Total Premium';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">' . $total_label . '</th>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
|
|
$total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $Addon_list[0]['policy_name'] . '</td>';
|
|
if ($show_full_premium_breakdown) {
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['gst']) . '</td>';
|
|
}
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr>';
|
|
|
|
$sum_total_words = numberToWords($total_addon);
|
|
$table_content .= '<tr>';
|
|
if ($show_full_premium_breakdown) {
|
|
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
|
|
} else {
|
|
$table_content .= '<td><b>' . $total_label . '</b></td>';
|
|
}
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div></div>';
|
|
}
|
|
}
|
|
|
|
$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 = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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 == 'account_maneger_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
|
|
];
|
|
|
|
$notification_data = $params['notification_data'];
|
|
$client_data = $params['client_data'];
|
|
$mail = $params['test_mail'];
|
|
|
|
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);
|
|
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
// Step 1: Replace the placeholder with an HTML table structure
|
|
$table_content = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
$Addon_list = [];
|
|
$name = $array_list['name'];
|
|
$emp_code = '';
|
|
|
|
if (!empty($array_list)) {
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
|
|
|
|
$policy_name = $array_list['policy_name'];
|
|
|
|
if ($array_list['relationship'] == 'Self') {
|
|
// $emp_code = ' (' . $array_list['emp_code'] . ')';
|
|
$emp_code = ' ( Employee Code : ' . $array_list['emp_code'] . ')';
|
|
} else {
|
|
$emp_code = '';
|
|
}
|
|
|
|
// Start table row
|
|
$table_content .= $policy_name . '</h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Relation</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Date Of Birth</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Sum Insured</th>';
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Premium</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Table body with details
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td>' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $array_list['relationship'] . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($array_list['basic_cover_si']) . '</td>';
|
|
|
|
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['premium'])) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['gst'])) . '</td>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
// 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,
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
|
|
$Addon_list[] = $addon_list_array;
|
|
}
|
|
|
|
// Generate summary table for addon if applicable
|
|
if (count($Addon_list) > 0) {
|
|
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Policy Name</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Additional Premium</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Total</th>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
|
|
$total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $Addon_list[0]['policy_name'] . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['gst']) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr>';
|
|
|
|
$sum_total_words = numberToWords($total_addon);
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr style="padding: 8px; white-space: nowrap;">';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div></div>';
|
|
}
|
|
}
|
|
|
|
$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 = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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') {
|
|
|
|
$array_list = [
|
|
'policy_name' => 'Health Insurance Plan',
|
|
'emp_code' => 'E12345',
|
|
'name' => 'Ramakrishnaparamahamsar',
|
|
'relationship' => 'Self',
|
|
'dob' => '1985-05-15',
|
|
'basic_cover_si' => 500000,
|
|
'premium' => 12000,
|
|
'gst' => 2160,
|
|
'rata_premimum' => 12000,
|
|
'is_addon' => 2
|
|
];
|
|
|
|
$notification_data = $params['notification_data'];
|
|
$client_data = $params['client_data'];
|
|
$mail = $params['test_mail'];
|
|
|
|
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}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
|
$mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
|
|
|
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
|
|
|
// Step 1: Replace the placeholder with an HTML table structure
|
|
$table_content = '';
|
|
$addtional_premium = 0;
|
|
$gst = 0;
|
|
$Addon_list = [];
|
|
$name = $array_list['name'];
|
|
$emp_code = '';
|
|
|
|
if (!empty($array_list)) {
|
|
|
|
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>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 . '</h4></div>';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th>Name</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Relation</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Date Of Birth</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Sum Insured</th>';
|
|
|
|
// Only Display SI Topup and Dependent Addon
|
|
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Premium</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
// Table body with details
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td>' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $array_list['relationship'] . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($array_list['basic_cover_si']) . '</td>';
|
|
|
|
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['premium'])) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['gst'])) . '</td>';
|
|
}
|
|
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div>';
|
|
|
|
// 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,
|
|
'addtional_premium' => round($addtional_premium),
|
|
'gst' => round($gst)
|
|
];
|
|
|
|
$Addon_list[] = $addon_list_array;
|
|
}
|
|
|
|
// Generate summary table for addon if applicable
|
|
if (count($Addon_list) > 0) {
|
|
|
|
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
|
|
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
|
|
|
|
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Policy Name</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Additional Premium</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
|
|
$table_content .= '<th style="padding: 8px; white-space: nowrap;">Total</th>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</thead>';
|
|
|
|
$table_content .= '<tbody style="text-align: center;">';
|
|
|
|
$total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $Addon_list[0]['policy_name'] . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['gst']) . '</td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr>';
|
|
|
|
$sum_total_words = numberToWords($total_addon);
|
|
$table_content .= '<tr>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;"></td style="padding: 8px; white-space: nowrap;"><td style="padding: 8px; white-space: nowrap;"></td><td style="padding: 8px; white-space: nowrap;"><b>Total</b></td>';
|
|
$table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
|
|
$table_content .= '</tr>';
|
|
$table_content .= '</tbody>';
|
|
$table_content .= '</table></div></div>';
|
|
}
|
|
}
|
|
|
|
$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 = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
|
|
|
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
|
$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;
|
|
}
|
|
}
|
|
}
|
|
}
|