CHANGE_Member_Review_And_Summary_Mail : AADHAVAN

This commit is contained in:
aadhavan valli 2024-07-16 17:48:11 +05:30
parent 8f57f3e8b1
commit 59dc24596b
3 changed files with 110 additions and 31 deletions

View File

@ -165,7 +165,7 @@ class sendMailNotification
$is_addon ='';
foreach ($item as $inner_item) {
$policy_name = $inner_item['policy_name'];
$temp_data .= '<tr ><td style="width:20%">' . $inner_item['name'] . '</td><td style="width:20%">'.$inner_item['mobile'].'</td><td style="width:20%">₹'.number_format($inner_item['basic_cover_si'], 2, '.', ',').'</td><td style="width:20%">'.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').'</tr>';
$temp_data .= '<tr ><td style="width:20%">' . $inner_item['name'] . '</td><td style="width:20%">'.$inner_item['relationship'].'</td><td>'. \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') .'</td><td style="width:20%">₹'.format_indian_number($inner_item['basic_cover_si']).'</td><td style="width:20%">₹'.format_indian_number($inner_item['premium']).'</td><td>₹'. format_indian_number($inner_item['gst']) .'</td></tr><tr>';
if($inner_item['relationship'] == 'Self' || $inner_item['relationship'] == 'self'){
$mail = $inner_item['email_corporate'];
$name = $inner_item['name'];
@ -179,10 +179,10 @@ class sendMailNotification
}
}
// echo $policy_name;die;
$table_content .= $policy_name.'</h4></div><table style="width:60%"><thead style="background-color: #02a8b5;"><tr><th style="width:20%">Name</th><th>Mobile Number</th><th>Sum Insure</th><th style="width:15%">Date Of Birth</th></tr></thead><tbody>';
$table_content .= $policy_name.'</h4></div><table style="width:60%"><thead style="background-color: #02a8b5;"><tr><th style="width:20%">Name</th><th>Relation</th><th style="width:15%">Date Of Birth</th><th>Sum Insure</th><th>Premium</th><tj>GST</th></tr></thead><tbody>';
$table_content .= $temp_data;
$table_content .= '</tbody></table></div>';
$Addon_list = [];
if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [
'policy_name'=>$policy_name,
@ -200,17 +200,20 @@ class sendMailNotification
}
}
if(count($Addon_list) != 0 && count($Addon_list) > 0){
$table_content .='<br><div style="text-align: left;"><div style="text-align:left;"><table style="width:60%"><thead style="background-color: #e26828;"><tr><th>Policy Name</th><th> Additional Premium</th><th>GST</th><th>Total</th></tr></thead><tbody>';
$sum_tolal = 0;
foreach ($Addon_list as $key => $value) {
$sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
$table_content .= '<tr><td>'.$value['policy_name'].'</td><td>₹'.$value['addtional_premium'].'</td><td>'.$value['gst'].'</td><td>'.$value['gst'] + $value['addtional_premium'] .'</td></tr>';
}
$sum_total_words = numberToWords($sum_tolal);
$table_content .= '<tr><td></td><td></td><td><h4>Total</h4></td><td>'.format_indian_number($sum_tolal).'</td></tr>';
$table_content .= '</tbody></table></div></div>';
$table_content .= '<div style="width:60%;text-align:right">'. $sum_total_words .'</div>';
$table_content .='<br><table style="width:60%"><thead style="background-color: #e26828;"><tr><th>Policy Name</th><th> Additional Premium</th><th>GST</th><th>Total</th></tr></thead><tbody>';
$sum_tolal = 0;
foreach ($Addon_list as $key => $value) {
$sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
$table_content .= '<tr><td>'.$value['policy_name'].'</td><td>₹'.$value['addtional_premium'].'</td><td>'.$value['gst'].'</td><td>'.$value['gst'] + $value['addtional_premium'] .'</td></tr>';
}
$table_content .= '<tr><td></td><td></td><td><h4>Total</h4></td><td>'.$sum_tolal.'</td></tr>';
$table_content .= '</tbody></table>';
$mail_content = str_replace("[[member_name]]", $name, $mail_content);
$mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
// $mail = "aadhavanvalli@gmail.com";
// if (isset($mail) && !empty($mail)) {
@ -276,7 +279,7 @@ class sendMailNotification
$is_addon ='';
foreach ($item as $inner_item) {
$policy_name = $inner_item['policy_name'];
$temp_data .= '<tr ><td style="width:20%">' . $inner_item['name'] . '</td><td style="width:20%">'.$inner_item['mobile'].'</td><td style="width:20%">₹'.number_format($inner_item['basic_cover_si'], 2, '.', ',').'</td><td style="width:20%">'.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').'</tr>';
$temp_data .= '<tr ><td style="width:20%">' . $inner_item['name'] . '</td><td style="width:20%">'.$inner_item['mobile'].'</td><td style="width:20%">₹'.format_indian_number($inner_item['basic_cover_si']).'</td><td style="width:20%">'.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').'</tr>';
// print_r($inner_item);die;
$is_addon = $inner_item['is_addon'];
@ -288,7 +291,7 @@ class sendMailNotification
$table_content .= $policy_name.'</h4></div><table style="width:60%"><thead style="background-color: #02a8b5;"><tr><th style="width:20%">Name</th><th>Mobile Number</th><th>Sum Insure</th><th style="width:15%">Date Of Birth</th></tr></thead><tbody>';
$table_content .= $temp_data;
$table_content .= '</tbody></table></div>';
$Addon_list = [];
if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [
'policy_name'=>$policy_name,
@ -307,16 +310,20 @@ class sendMailNotification
}
if(count($Addon_list) != 0 && count($Addon_list) > 0){
$table_content .='<br><div style="text-align: left;"><div style="text-align:left;"><table style="width:60%"><thead style="background-color: #e26828;"><tr><th>Policy Name</th><th> Additional Premium</th><th>GST</th><th>Total</th></tr></thead><tbody>';
$sum_tolal = 0;
foreach ($Addon_list as $key => $value) {
$sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
$table_content .= '<tr><td>'.$value['policy_name'].'</td><td>₹'.$value['addtional_premium'].'</td><td>'.$value['gst'].'</td><td>'.$value['gst'] + $value['addtional_premium'] .'</td></tr>';
}
$sum_total_words = numberToWords($sum_tolal);
$table_content .= '<tr><td></td><td></td><td><h4>Total</h4></td><td>'.format_indian_number($sum_tolal).'</td></tr>';
$table_content .= '</tbody></table></div></div>';
$table_content .= '<div style="width:60%;text-align:right">'. $sum_total_words .'</div>';
$table_content .='<br><table style="width:60%"><thead style="background-color: #e26828;"><tr><th>Policy Name</th><th> Additional Premium</th><th>GST</th><th>Total</th></tr></thead><tbody>';
$sum_tolal = 0;
foreach ($Addon_list as $key => $value) {
$sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
$table_content .= '<tr><td>'.$value['policy_name'].'</td><td>₹'.$value['addtional_premium'].'</td><td>'.$value['gst'].'</td><td>'.$value['gst'] + $value['addtional_premium'] .'</td></tr>';
}
$table_content .= '<tr><td></td><td></td><td><h4>Total</h4></td><td>'.$sum_tolal.'</td></tr>';
$table_content .= '</tbody></table>';
$mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
$account_manager_mail_list = [];
@ -383,7 +390,7 @@ class sendMailNotification
$temp_data ='';
foreach ($item as $inner_item) {
$policy_name = $inner_item['policy_name'];
$temp_data .= '<tr ><td style="width:20%">' . $inner_item['name'] . '</td><td style="width:20%">'.$inner_item['mobile'].'</td><td style="width:20%">₹'.number_format($inner_item['basic_cover_si'], 2, '.', ',').'</td><td style="width:20%">'.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').'</tr>';
$temp_data .= '<tr ><td style="width:20%">' . $inner_item['name'] . '</td><td style="width:20%">'.$inner_item['mobile'].'</td><td style="width:20%">₹'.format_indian_number($inner_item['basic_cover_si']).'</td><td style="width:20%">'.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').'</tr>';
// print_r($inner_item);die;
$is_addon = $inner_item['is_addon'];
@ -395,6 +402,7 @@ class sendMailNotification
$table_content .= $policy_name.'</h4></div><table style="width:60%"><thead style="background-color: #02a8b5;"><tr><th style="width:20%">Name</th><th>Mobile Number</th><th>Sum Insure</th><th style="width:15%">Date Of Birth</th></tr></thead><tbody>';
$table_content .= $temp_data;
$table_content .= '</tbody></table></div>';
$Addon_list = [];
if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [
@ -412,16 +420,18 @@ class sendMailNotification
$gst = 0;
}
$table_content .='<br><table style="width:60%"><thead style="background-color: #e26828;"><tr><th>Policy Name</th><th> Additional Premium</th><th>GST</th><th>Total</th></tr></thead><tbody>';
$sum_tolal = 0;
foreach ($Addon_list as $key => $value) {
$sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
$table_content .= '<tr><td>'.$value['policy_name'].'</td><td>₹'.$value['addtional_premium'].'</td><td>'.$value['gst'].'</td><td>'.$value['gst'] + $value['addtional_premium'] .'</td></tr>';
if(count($Addon_list) != 0 && count($Addon_list) > 0){
$table_content .='<br><div style="text-align: left;"><div style="text-align:left;"><table style="width:60%"><thead style="background-color: #e26828;"><tr><th>Policy Name</th><th> Additional Premium</th><th>GST</th><th>Total</th></tr></thead><tbody>';
$sum_tolal = 0;
foreach ($Addon_list as $key => $value) {
$sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
$table_content .= '<tr><td>'.$value['policy_name'].'</td><td>₹'.$value['addtional_premium'].'</td><td>'.$value['gst'].'</td><td>'.$value['gst'] + $value['addtional_premium'] .'</td></tr>';
}
$sum_total_words = numberToWords($sum_tolal);
$table_content .= '<tr><td></td><td></td><td><h4>Total</h4></td><td>'.format_indian_number($sum_tolal).'</td></tr>';
$table_content .= '</tbody></table></div></div>';
$table_content .= '<div style="width:60%;text-align:right">'. $sum_total_words .'</div>';
}
$table_content .= '<tr><td></td><td></td><td><h4>Total</h4></td><td>'.$sum_tolal.'</td></tr>';
$table_content .= '</tbody></table>';
$mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
@ -439,4 +449,6 @@ class sendMailNotification
}
}
}

View File

@ -139,3 +139,9 @@ if (!function_exists('get_session_context')) {
return $session->get('context');
}
}

View File

@ -248,3 +248,64 @@ if (!function_exists('get_role_id')) {
}
function numberToWords($number)
{
$words = array(
'0' => 'Zero',
'1' => 'One',
'2' => 'Two',
'3' => 'Three',
'4' => 'Four',
'5' => 'Five',
'6' => 'Six',
'7' => 'Seven',
'8' => 'Eight',
'9' => 'Nine',
'10' => 'Ten',
'11' => 'Eleven',
'12' => 'Twelve',
'13' => 'Thirteen',
'14' => 'Fourteen',
'15' => 'Fifteen',
'16' => 'Sixteen',
'17' => 'Seventeen',
'18' => 'Eighteen',
'19' => 'Nineteen',
'20' => 'Twenty',
'30' => 'Thirty',
'40' => 'Forty',
'50' => 'Fifty',
'60' => 'Sixty',
'70' => 'Seventy',
'80' => 'Eighty',
'90' => 'Ninety'
);
if ($number < 21) {
return $words[$number];
}
if ($number < 100) {
$tens = (int)($number / 10) * 10;
$units = $number % 10;
return $words[$tens] . ($units ? ' ' . $words[$units] : '');
}
if ($number < 1000) {
$hundreds = (int)($number / 100);
$remainder = $number % 100;
return $words[$hundreds] . ' Hundred' . ($remainder ? ' and ' . numberToWords($remainder) : '');
}
$levels = array('', ' Thousand', ' Million', ' Billion', ' Trillion', ' Quadrillion', ' Quintillion');
for ($i = 0, $unit = 1; $i < count($levels); $i++, $unit *= 1000) {
if ($number < $unit * 1000) {
$current = (int)($number / $unit);
$remainder = $number % $unit;
return numberToWords($current) . $levels[$i] . ($remainder ? ' ' . numberToWords($remainder) : '');
}
}
return $number; // Fallback for numbers beyond the supported range
}