CHANGE_SENDMAIL_NOTIFICATION_FAMILY_FLOATERS_AND_INDIVIDUALS : RV

This commit is contained in:
VENKATESHWARAN 2024-10-14 19:16:15 +05:30
parent 973c5a7b42
commit 201296fda2
3 changed files with 147 additions and 24 deletions

View File

@ -119,7 +119,7 @@ class ClientController extends AdminController
{ {
$emp_code = 'MGL-004'; $emp_code = 'MGL-004';
$client_id = 77; $client_id = 77;
$client_policy_id = 206; $client_policy_id = 205;
$array_list = []; $array_list = [];
$find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $client_policy_id, emp_code: $emp_code, client_id: $client_id, emp_status: ['draft', 'enrolled'], policy_status: ['draft', 'enrolled']); $find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $client_policy_id, emp_code: $emp_code, client_id: $client_id, emp_status: ['draft', 'enrolled'], policy_status: ['draft', 'enrolled']);
@ -915,6 +915,7 @@ class ClientController extends AdminController
$data['client_branch_id'] = $this->request->getPost('client_branch_id'); $data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); $data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst'); $data['gst'] = $this->request->getPost('gst');
$data['disclaimer'] = $this->request->getPost('disclaimer');
if ($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7) { if ($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7) {
@ -1041,6 +1042,7 @@ class ClientController extends AdminController
$data['client_branch_id'] = $this->request->getPost('client_branch_id'); $data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); $data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst'); $data['gst'] = $this->request->getPost('gst');
$data['disclaimer'] = $this->request->getPost('disclaimer');
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'); $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'); $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');

View File

@ -3,10 +3,13 @@
namespace App\Helpers; namespace App\Helpers;
use App\Models\ClientModel; use App\Models\ClientModel;
use App\Models\ClientPolicyModel;
use App\Models\ClientRMModel; use App\Models\ClientRMModel;
use App\Models\NotificationModel; use App\Models\NotificationModel;
use App\Models\UserModel; use App\Models\UserModel;
use App\Models\EmployeeModel; use App\Models\EmployeeModel;
use App\Models\PolicyPremium1Model;
use App\Models\PolicyPremium2Model;
class sendMailNotification class sendMailNotification
{ {
@ -169,10 +172,22 @@ class sendMailNotification
$clientModel = new ClientModel(); $clientModel = new ClientModel();
$notificationModel = new NotificationModel(); $notificationModel = new NotificationModel();
$clientPolicyModel = new ClientPolicyModel();
$PolicyPremium1Model = new PolicyPremium1Model();
$PolicyPremium2Model = new PolicyPremium2Model();
$client_data =$clientModel->where('id', $client_id)->first(); $client_data =$clientModel->where('id', $client_id)->first();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
$client_policy_data = $clientPolicyModel->where('id', $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', $client_policy_id)->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $client_policy_id)->first();
}
// dd($notification_data); // dd($notification_data);
if (isset($notification_data) && $notification_data['enabled'] == 1) { if (isset($notification_data) && $notification_data['enabled'] == 1) {
@ -200,14 +215,21 @@ class sendMailNotification
$name = ''; $name = '';
$emp_code = ''; $emp_code = '';
// echo '<pre>';
// print_r($array_list); die;
foreach ($array_list as $item) { foreach ($array_list as $item) {
if (count($item) != 0) { if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Name : ';
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = ''; $temp_data = '';
$policy_name = ''; $policy_name = '';
$is_addon = ''; $is_addon = '';
foreach ($item as $inner_item) { foreach ($item as $inner_item) {
$policy_name = $inner_item['policy_name']; $policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') { if ($inner_item['relationship'] == 'Self') {
@ -215,17 +237,27 @@ class sendMailNotification
} else { } else {
$emp_code = ''; $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 .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>'; $temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</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>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
$temp_data .= '<td>₹' . format_indian_number($inner_item['basic_cover_si']) . '</td>'; $temp_data .= '<td>' . $si . '</td>';
// Only Display SI Topup and Dependent Addon // Only Display SI Topup and Dependent Addon
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['premium'])) . '</td>'; $temp_data .= '<td>' . $premium . '</td>';
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['gst'])) . '</td>'; $temp_data .= '<td>' . $gst_forself . '</td>';
} }
$temp_data .= '</tr>'; $temp_data .= '</tr>';
@ -237,8 +269,13 @@ class sendMailNotification
$gst = $inner_item['gst'] + $gst; $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 . '</h4></div>'; $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;">'; $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 // Add text-align: center to the table head
@ -264,7 +301,7 @@ class sendMailNotification
if ($is_addon == 2 || $is_addon == 3) { if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [ $addon_list_array = [
'policy_name' => $policy_name, 'policy_name' => $policy_name_for_policy_type,
'addtional_premium' => round($addtional_premium), 'addtional_premium' => round($addtional_premium),
'gst' => round($gst) 'gst' => round($gst)
]; ];
@ -316,8 +353,6 @@ class sendMailNotification
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>'; // $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
} }
// print_r($table_content); die; // print_r($table_content); die;
$mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content); $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content);
@ -337,14 +372,27 @@ class sendMailNotification
} else if($action == 'account_maneger_summary_mail'){ } else if($action == 'account_maneger_summary_mail'){
$client_id = $params['client_id']; $client_id = $params['client_id'];
$client_policy_id = $params['client_policy_id'];
$clientModel = new ClientModel(); $clientModel = new ClientModel();
$notificationModel = new NotificationModel(); $notificationModel = new NotificationModel();
$clientRMModel =new ClientRMModel(); $clientRMModel =new ClientRMModel();
$clientPolicyModel = new ClientPolicyModel();
$PolicyPremium1Model = new PolicyPremium1Model();
$PolicyPremium2Model = new PolicyPremium2Model();
$client_data =$clientModel->where('id', $client_id)->first(); $client_data =$clientModel->where('id', $client_id)->first();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
$client_policy_data = $clientPolicyModel->where('id', $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', $client_policy_id)->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $client_policy_id)->first();
}
if (isset($notification_data) && $notification_data['enabled'] == 1) { if (isset($notification_data) && $notification_data['enabled'] == 1) {
$client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll(); $client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
@ -381,12 +429,13 @@ class sendMailNotification
foreach ($array_list as $item) { foreach ($array_list as $item) {
if (count($item) != 0) { if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Name : '; $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = ''; $temp_data = '';
$policy_name = ''; $policy_name = '';
$is_addon = ''; $is_addon = '';
foreach ($item as $inner_item) { foreach ($item as $inner_item) {
$policy_name = $inner_item['policy_name']; $policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') { if ($inner_item['relationship'] == 'Self') {
@ -394,17 +443,26 @@ class sendMailNotification
} else { } else {
$emp_code = ''; $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 .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>'; $temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</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>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
$temp_data .= '<td>₹' . format_indian_number($inner_item['basic_cover_si']) . '</td>'; $temp_data .= '<td>' . $si . '</td>';
// Only Display SI Topup and Dependent Addon // Only Display SI Topup and Dependent Addon
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
$temp_data .= '<td>' . format_indian_number(round($inner_item['premium'])) . '</td>'; $temp_data .= '<td>' . $premium . '</td>';
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['gst'])) . '</td>'; $temp_data .= '<td>' . $gst_forself . '</td>';
} }
$temp_data .= '</tr>'; $temp_data .= '</tr>';
@ -416,8 +474,13 @@ class sendMailNotification
$gst = $inner_item['gst'] + $gst; $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 . '</h4></div>'; $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;">'; $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 // Add text-align: center to the table head
@ -443,7 +506,7 @@ class sendMailNotification
if ($is_addon == 2 || $is_addon == 3) { if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [ $addon_list_array = [
'policy_name' => $policy_name, 'policy_name' => $policy_name_for_policy_type,
'addtional_premium' => round($addtional_premium), 'addtional_premium' => round($addtional_premium),
'gst' => round($gst) 'gst' => round($gst)
]; ];
@ -513,14 +576,28 @@ class sendMailNotification
} else if($action == 'client_hr_summary_mail'){ } else if($action == 'client_hr_summary_mail'){
$client_id = $params['client_id']; $client_id = $params['client_id'];
$client_policy_id = $params['client_policy_id'];
$clientModel = new ClientModel(); $clientModel = new ClientModel();
$clientPolicyModel = new ClientPolicyModel();
$PolicyPremium1Model = new PolicyPremium1Model();
$PolicyPremium2Model = new PolicyPremium2Model();
$client_data =$clientModel->where('id', $client_id)->first(); $client_data =$clientModel->where('id', $client_id)->first();
$notificationModel = new NotificationModel(); $notificationModel = new NotificationModel();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
$clientRMModel =new ClientRMModel(); $clientRMModel =new ClientRMModel();
$client_policy_data = $clientPolicyModel->where('id', $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', $client_policy_id)->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $client_policy_id)->first();
}
if (isset($notification_data['enabled']) && $notification_data['enabled'] == 1) { if (isset($notification_data['enabled']) && $notification_data['enabled'] == 1) {
$client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll(); $client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
$user_list= []; $user_list= [];
@ -558,7 +635,7 @@ class sendMailNotification
foreach ($array_list as $item) { foreach ($array_list as $item) {
if (count($item) != 0) { if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Name : '; $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = ''; $temp_data = '';
$policy_name = ''; $policy_name = '';
$is_addon = ''; $is_addon = '';
@ -571,17 +648,29 @@ class sendMailNotification
} else { } else {
$emp_code = ''; $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 .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>'; $temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</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>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
$temp_data .= '<td>₹' . format_indian_number($inner_item['basic_cover_si']) . '</td>'; $temp_data .= '<td>' . $si . '</td>';
// Only Display SI Topup and Dependent Addon // Only Display SI Topup and Dependent Addon
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['premium'])) . '</td>'; $temp_data .= '<td>' . $premium . '</td>';
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['gst'])) . '</td>'; $temp_data .= '<td>' . $gst_forself . '</td>';
} }
$temp_data .= '</tr>'; $temp_data .= '</tr>';
@ -594,7 +683,12 @@ class sendMailNotification
} }
} }
$table_content .= $policy_name . '</h4></div>'; $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;">'; $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 // Add text-align: center to the table head
@ -620,7 +714,7 @@ class sendMailNotification
if ($is_addon == 2 || $is_addon == 3) { if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [ $addon_list_array = [
'policy_name' => $policy_name, 'policy_name' => $policy_name_for_policy_type,
'addtional_premium' => round($addtional_premium), 'addtional_premium' => round($addtional_premium),
'gst' => round($gst) 'gst' => round($gst)
]; ];
@ -836,7 +930,7 @@ class sendMailNotification
if (!empty($array_list)) { if (!empty($array_list)) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Name : '; $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$policy_name = $array_list['policy_name']; $policy_name = $array_list['policy_name'];
@ -985,7 +1079,7 @@ class sendMailNotification
$emp_code = ''; $emp_code = '';
if (!empty($array_list)) { if (!empty($array_list)) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Name : '; $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$policy_name = $array_list['policy_name']; $policy_name = $array_list['policy_name'];
@ -1133,7 +1227,7 @@ class sendMailNotification
if (!empty($array_list)) { if (!empty($array_list)) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Name : '; $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$policy_name = $array_list['policy_name']; $policy_name = $array_list['policy_name'];

View File

@ -375,7 +375,34 @@ if (!function_exists('excelFileGDriveUpload')) {
} }
} }
if(!function_exists('checkFamilyFloaters')){
function checkFamilyFloaters($policy_premium_data, $client_policy_data, $emp_data){
if($policy_premium_data['premium_type'] == 1){
//only family floater
if ($emp_data['relationship'] == 'Self') {
return true;
}
if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){
if($emp_data['rata_premimum'] > 0){
return true;
}else{
return false;
}
}
return false;
}else{
//individual
return true;
}
}
}
function numberToWords($number) function numberToWords($number)