From 3ebc859692ecebdf86cada3b4fba3dd2bd19594a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 10 Oct 2024 12:34:57 +0530 Subject: [PATCH 01/10] CHANGE_SENDMAIL_NOTIFICATION_TABLE_TEXT_CENTER_ALIGN : RV --- app/Helpers/sendMailNotification.php | 175 ++++++++++++++++----------- 1 file changed, 103 insertions(+), 72 deletions(-) diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 0865865a..5779135f 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -189,64 +189,66 @@ class sendMailNotification foreach ($array_list as $item) { if (count($item) != 0) { - $table_content .= '
'; - $table_content .= '

Policy Name : '; + $table_content .= '

Policy Name : '; $temp_data = ''; $policy_name = ''; $is_addon = ''; - + foreach ($item as $inner_item) { $policy_name = $inner_item['policy_name']; - $temp_data .= ''; - $temp_data .= '' . $inner_item['name'] . ''; + + if ($inner_item['relationship'] == 'Self') { + $emp_code = ' (' . $inner_item['emp_code'] . ')'; + } else { + $emp_code = ''; + } + + $temp_data .= ''; + $temp_data .= '' . $inner_item['name'] . $emp_code . ''; $temp_data .= '' . $inner_item['relationship'] . ''; $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; $temp_data .= '₹' . format_indian_number($inner_item['basic_cover_si']) . ''; - - //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) { $temp_data .= '₹' . format_indian_number(round($inner_item['premium'])) . ''; $temp_data .= '₹' . format_indian_number(round($inner_item['gst'])) . ''; } - + $temp_data .= ''; - - - - if ($inner_item['relationship'] == 'Self' || $inner_item['relationship'] == 'self') { - $mail = $inner_item['email_corporate']; - $name = $inner_item['name']; - $emp_code = $inner_item['emp_code']; - } - + $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; } } - + $table_content .= $policy_name . '

'; $table_content .= ''; - $table_content .= ''; + + // Add text-align: center to the table head + $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; - - //Only Display SI Topup and Dependent Addon + + // Only Display SI Topup and Dependent Addon if ($is_addon == 2 || $is_addon == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; - $table_content .= '' . $temp_data . ''; + + // Add text-align: center to the table body + $table_content .= '' . $temp_data . ''; $table_content .= '
NameRelationDate Of BirthSum InsuredPremiumGST
'; - + if ($is_addon == 2 || $is_addon == 3) { $addon_list_array = [ 'policy_name' => $policy_name, @@ -255,36 +257,52 @@ class sendMailNotification ]; $Addon_list[] = $addon_list_array; } - + $temp_data = ''; $addtional_premium = 0; $gst = 0; } } - - if (count($Addon_list) != 0 && count($Addon_list) > 0) { - - $table_content .= '
'; - $table_content .= '
'; - $table_content .= ''; - $table_content .= ''; - $table_content .= ''; - $table_content .= ''; - $sum_tolal = 0; - + + if (count($Addon_list) > 0) { + $table_content .= '
'; + $table_content .= '
Policy NameAdditional PremiumGSTTotal
'; + + // Center align for table header and body + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $table_content .= ''; + + $sum_total = 0; foreach ($Addon_list as $key => $value) { - $sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal; - $table_content .= ''; + $total_addon = $value['gst'] + $value['addtional_premium']; + $sum_total += $total_addon; + + $table_content .= ''; + $table_content .= ''; $table_content .= ''; $table_content .= ''; - $table_content .= ''; + $table_content .= ''; + $table_content .= ''; } - - $sum_total_words = numberToWords($sum_tolal); - $table_content .= ''; - $table_content .= '
Policy NameAdditional PremiumGSTTotal
' . $value['policy_name'] . '
' . $value['policy_name'] . '₹' . format_indian_number($value['addtional_premium']) . '₹' . format_indian_number($value['gst']) . '₹' . format_indian_number(($value['gst'] + $value['addtional_premium'])) . '
₹' . format_indian_number($total_addon) . '
Total₹' . format_indian_number($sum_tolal) . '
'; - // $table_content .= '
' . $sum_total_words . '
'; + + $sum_total_words = numberToWords($sum_total); + $table_content .= ''; + $table_content .= 'Total'; + $table_content .= '₹' . format_indian_number($sum_total) . ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= '

'; + // $table_content .= '
' . $sum_total_words . '
'; } + // print_r($table_content); die; @@ -349,7 +367,6 @@ class sendMailNotification $Addon_list = []; foreach ($array_list as $item) { - if (count($item) != 0) { $table_content .= '

Policy Name : '; $temp_data = ''; @@ -364,19 +381,19 @@ class sendMailNotification } else { $emp_code = ''; } - + $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . $emp_code . ''; $temp_data .= '' . $inner_item['relationship'] . ''; $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; $temp_data .= '₹' . format_indian_number($inner_item['basic_cover_si']) . ''; - - //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) { $temp_data .= '₹' . format_indian_number(round($inner_item['premium'])) . ''; $temp_data .= '₹' . format_indian_number(round($inner_item['gst'])) . ''; } - + $temp_data .= ''; $is_addon = $inner_item['is_addon']; @@ -389,22 +406,26 @@ class sendMailNotification $table_content .= $policy_name . '

'; $table_content .= ''; - $table_content .= ''; + + // Add text-align: center to the table head + $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; - - //Only Display SI Topup and Dependent Addon + + // Only Display SI Topup and Dependent Addon if ($is_addon == 2 || $is_addon == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; - $table_content .= '' . $temp_data . ''; + + // Add text-align: center to the table body + $table_content .= '' . $temp_data . ''; $table_content .= '
NameRelationDate Of BirthSum InsuredPremiumGST
'; if ($is_addon == 2 || $is_addon == 3) { @@ -425,7 +446,9 @@ class sendMailNotification if (count($Addon_list) > 0) { $table_content .= '
'; $table_content .= ''; - $table_content .= ''; + + // Center align for table header and body + $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; @@ -433,8 +456,9 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - $table_content .= ''; - + + $table_content .= ''; + $sum_total = 0; foreach ($Addon_list as $key => $value) { $total_addon = $value['gst'] + $value['addtional_premium']; @@ -457,6 +481,7 @@ class sendMailNotification $table_content .= '
Policy NameAdditional PremiumTotal
'; // $table_content .= '
' . $sum_total_words . '
'; } + $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); @@ -519,7 +544,6 @@ class sendMailNotification $Addon_list = []; foreach ($array_list as $item) { - if (count($item) != 0) { $table_content .= '

Policy Name : '; $temp_data = ''; @@ -534,19 +558,19 @@ class sendMailNotification } else { $emp_code = ''; } - + $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . $emp_code . ''; $temp_data .= '' . $inner_item['relationship'] . ''; $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; $temp_data .= '₹' . format_indian_number($inner_item['basic_cover_si']) . ''; - - //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) { $temp_data .= '₹' . format_indian_number(round($inner_item['premium'])) . ''; $temp_data .= '₹' . format_indian_number(round($inner_item['gst'])) . ''; } - + $temp_data .= ''; $is_addon = $inner_item['is_addon']; @@ -559,22 +583,26 @@ class sendMailNotification $table_content .= $policy_name . '

'; $table_content .= ''; - $table_content .= ''; + + // Add text-align: center to the table head + $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; - - //Only Display SI Topup and Dependent Addon + + // Only Display SI Topup and Dependent Addon if ($is_addon == 2 || $is_addon == 3) { $table_content .= ''; $table_content .= ''; } - + $table_content .= ''; $table_content .= ''; - $table_content .= '' . $temp_data . ''; + + // Add text-align: center to the table body + $table_content .= '' . $temp_data . ''; $table_content .= '
NameRelationDate Of BirthSum InsuredPremiumGST
'; if ($is_addon == 2 || $is_addon == 3) { @@ -595,7 +623,9 @@ class sendMailNotification if (count($Addon_list) > 0) { $table_content .= '
'; $table_content .= ''; - $table_content .= ''; + + // Center align for table header and body + $table_content .= ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; @@ -603,8 +633,9 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= ''; - $table_content .= ''; - + + $table_content .= ''; + $sum_total = 0; foreach ($Addon_list as $key => $value) { $total_addon = $value['gst'] + $value['addtional_premium']; @@ -627,7 +658,7 @@ class sendMailNotification $table_content .= '
Policy NameAdditional PremiumTotal
'; // $table_content .= '
' . $sum_total_words . '
'; } - + $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); From 30f16d1e17e1e41af7694d0c9a843d6f0d606669 Mon Sep 17 00:00:00 2001 From: Smart Date: Thu, 10 Oct 2024 15:41:58 +0530 Subject: [PATCH 02/10] CHANGE_ in basic_cover_si : GWM --- app/Controllers/EmployeeRestController.php | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 3034ece9..5add343a 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -999,7 +999,7 @@ class EmployeeRestController extends AdminController $self['data']['dob'] = $this->convertDateFormatDMY($selfData[0]['dob']); $self['data']['mobile'] = $selfData[0]['mobile']; $self['data']['client_policy_id'] = $array->ClientPolicyId; - $self['data']['basic_cover_si'] = $employee_policy->basic_cover_si; + $self['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : 0; $array->mapped_family_floaters = $self; $array->type = 'GPA'; @@ -1056,6 +1056,7 @@ class EmployeeRestController extends AdminController foreach ($empData as $key => $value) { if ($value['family_floater_key'] === $dependent) { $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); + $temp['is_value_exist'] = true; $temp['data']['family_floater_key'] = $familyFloatesValue; $temp['data']['employee_id'] = $value['id']; @@ -1064,7 +1065,7 @@ class EmployeeRestController extends AdminController $temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']); $temp['data']['client_policy_id'] = $array->ClientPolicyId; $temp['data']['form_type'] = $dependent; - $temp['data']['basic_cover_si'] = $employee_policy->basic_cover_si; + $temp['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : 0; $temp['data']['age_validation'] = $this->getAgeRange($decodedArray,$familyFloatesValue); @@ -1164,7 +1165,7 @@ class EmployeeRestController extends AdminController return $this->respond(['status' => 'failed','code' => 404,'data' => []], 200); } } catch (\Exception $e) { - return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getLine()], 500); } } @@ -1260,7 +1261,7 @@ class EmployeeRestController extends AdminController $temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']); $temp['data']['client_policy_id'] = $array->ClientPolicyId; $temp['data']['form_type'] = $dependent; - $temp['data']['basic_cover_si'] = $employee_policy->basic_cover_si; + $temp['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : 0; $temp['data']['age_validation'] = $this->getAgeRange($array->Policy_Terms,$familyFloatesValue); @@ -1367,7 +1368,7 @@ class EmployeeRestController extends AdminController $self['data']['dob'] = $this->convertDateFormatDMY($selfData[0]['dob']); $self['data']['mobile'] = $selfData[0]['mobile']; $self['data']['client_policy_id'] = $array->ClientPolicyId; - $self['data']['basic_cover_si'] = $employee_policy->basic_cover_si; + $self['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : 0; $array->mapped_family_floaters = $self; if($array->enrolment_visibility == 1) @@ -1500,9 +1501,7 @@ class EmployeeRestController extends AdminController if(count($clientPolicy)) { - $self = $this->employeeModel - ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.is_active', 1) + $self = $this->employeeModel->where('employees.is_active', 1) ->where('employees.emp_code', $this->request->getGet('emp_code')) ->where('employees.client_id', $this->request->getGet('client_id')) ->where('employees.client_branch_id', $this->request->getGet('client_branch_id')) @@ -1586,8 +1585,18 @@ class EmployeeRestController extends AdminController if($array['is_addon'] == 3 && $array['policy_type_id'] == 3)//dependent add on policy { - - $selfSi = $self->basic_cover_si; + $selfGMC = $this->employeeModel->select('employees.name , employee_polices.basic_cover_si') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id AND client_policy.policy_type_id = 2') + ->where('employees.is_active', 1) + ->where('employees.emp_code', $this->request->getGet('emp_code')) + ->where('employees.client_id', $this->request->getGet('client_id')) + ->where('employees.client_branch_id', $this->request->getGet('client_branch_id')) + ->where('employees.family_floater_key', 'self') + ->get() + ->getRow(); + + $selfSi = $selfGMC->basic_cover_si; $filteredSlabRates = array_filter($responce['SlabRates'], function ($rate) use ($selfSi) { return $rate['si'] === $selfSi; }); From d26a8f79484b7c8ef3a08459149772d5b1b520c9 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 11 Oct 2024 09:38:19 +0530 Subject: [PATCH 03/10] CHANGE_MAIL_REPLY_TO_SETUP : RV --- app/Helpers/MailHelper.php | 13 +++++++++++-- app/Helpers/sendMailNotification.php | 24 +++++++++++++++++------- app/Models/ClientModel.php | 1 + 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index 9ff6a624..bddd1a49 100755 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -93,6 +93,8 @@ class MailHelper $emaill = $params['mail']; $subject = $params['subject']; $message = $params['message']; + + //check BCC mail if (isset($params['bcc'])) { $bcc = $params['bcc']; $bcc = explode(',', $bcc); @@ -100,16 +102,23 @@ class MailHelper $bcc = []; } + //check CC mail if (isset($params['cc'])) { $cc = $params['cc']; $cc = explode(',', $cc); }else{ $cc = []; } + + //check REPLY TO mail + $reply_to = ""; + if(isset($params['reply_to']) && !empty($params['reply_to'])){ + $reply_to = $params['reply_to']; + } + try { - - $res = $gmailapi->sendMessage($emaill, $subject, $message, 'info@nhanceindia.in', 'info@nhanceindia.in', $cc, $bcc); + $res = $gmailapi->sendMessage($emaill, $subject, $message, 'info@nhanceindia.in', $reply_to, $cc, $bcc); if($res['status']) { diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 5779135f..2802701a 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -14,6 +14,7 @@ class sendMailNotification { $wholeData =[]; if ($action == 'member_welcome_mail') { + $dataToInsert = $params['dataToInsert']; $notification = $params['notification']; $client_data = $params['client_data']; @@ -33,10 +34,13 @@ class sendMailNotification $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') { - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails']]; + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; } + return $wholeData; + } else if($action == 'member_reminder_mail'){ + $EmployeeModel = new EmployeeModel(); $emp_data = $params['emp_data']; $notification_data = $params['notification_data']; @@ -72,9 +76,11 @@ class sendMailNotification } if (isset($mail) && !empty($mail)) { - $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; + $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; } + }else{ + foreach ($emp_data as $key => $value) { if ($value['relationship'] != 'Self') { $emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll(); @@ -96,7 +102,7 @@ class sendMailNotification $mail = $value['email_corporate']; } if (isset($mail) && !empty($mail)) { - $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; + $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; } } } @@ -104,10 +110,13 @@ class sendMailNotification if (count($wholeData) < 1) { $wholeData = []; } + return $wholeData; + // }else{ // return "false"; // } + } else if($action == 'member_ecard_mail'){ $notification = $params['notification']; @@ -144,9 +153,10 @@ class sendMailNotification // $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content); $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails']]; + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; return $wholeData; + } else if($action == 'member_review_and_summary_mail'){ $array_list = $params['array_list'];//employeee lst @@ -314,7 +324,7 @@ class sendMailNotification // $mail = "aadhavanvalli@gmail.com"; // if (isset($mail) && !empty($mail)) { - $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; + $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; // } return $wholeData; @@ -491,7 +501,7 @@ class sendMailNotification $full_name = $value['first_name'] .' ' .$value['last_name']; $mail_content = str_replace("[[member_name]]", $full_name , $mail_content); - $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content]; + $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; // $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; } return $wholeData; @@ -667,7 +677,7 @@ class sendMailNotification $mail_array = array_map('trim', $mail_array); $wholeData = []; foreach ($mail_array as $key => $value) { - $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content]; + $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; // $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; } diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index ce5481d3..4e05f84a 100755 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -37,6 +37,7 @@ class ClientModel extends Model "reference", "phone", "email", + "reply_to", ]; From 4a13d7c7212569834ce6124885f0cecae18324a4 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 11 Oct 2024 13:49:09 +0530 Subject: [PATCH 04/10] CHANGE_UPDATE_ENROLLMENT_STATUS_FUNCTION AND_SEND_CRONE_MAIL_FUNCTION_FOR_REMAINDER_MAIL : RV --- app/Config/Routes.php | 7 +- app/Controllers/DashboardController.php | 228 ++++++++++++++++-------- app/Helpers/sendMailNotification.php | 3 + app/Models/ClientPolicyModel.php | 15 ++ 4 files changed, 177 insertions(+), 76 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index dd81efc5..6269cfd1 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -12,7 +12,9 @@ $routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']); // Reminder Mail Notification $routes->get("reminder_mail", "NotificationController::reminder_mail"); -$routes->get("testing", "ClientController::Testing"); +// $routes->get("testing", "ClientController::Testing"); +// $routes->get("testing", "DashboardController::updatePolicyEnrollmentStatus"); +$routes->get("testing", "DashboardController::sendCroneRemainderMail"); $routes->get("update-policy-terms-for-corrections", "ClientController::updatePolicyTermsForCorrections"); $routes->get("update_rack_rate_json", "ClientController::updateRackRateJson"); $routes->get("updatajson", "EmpDataServiceController::updatajson"); @@ -284,6 +286,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("get_policy_type_for_base_policy/(:any)", "ClientController::getPolicyTypeForBasePolicy/$1"); $routes->get("get_client_details/(:any)", "ClientController::getClientDetails/$1"); $routes->get("featch_dashboard_data/(:any)", "DashboardController::featch_dashboard_data/$1"); + $routes->get("send_manual_remainder/(:any)", "DashboardController::sendManualRemainder/$1"); $routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1"); $routes->get("rename_rack_rate_tab/(:any)", "ClientController::renameRackRateTab/$1"); $routes->post("create_excel_template", "MasterController::createExcelTemplate"); @@ -363,6 +366,8 @@ $routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken' $routes->cli('cli/send_mail_cli(/:any)?', 'MasterController::testGmailAPIViaCLI$1'); $routes->cli('cli/app_check_list', 'MasterController::appCheckList'); $routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken'); +$routes->cli('cli/updatePolicyEnrollmentStatus', 'DashboardController::updatePolicyEnrollmentStatus'); +$routes->cli('cli/sendCroneRemainderMail', 'DashboardController::sendCroneRemainderMail'); diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 71015045..079e4d35 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -202,59 +202,71 @@ class DashboardController extends AdminController public function updatePolicyEnrollmentStatus() { - $clientModel = new ClientModel(); $clientPolicyModel = new ClientPolicyModel(); - $notificationModel = new NotificationModel(); - $employeePolicyModel = new EmployeePolicyModel(); $myLogger = \Config\Services::mylogger(); - - // $myLogger->logme('error', 'enrollment_status function called'); - - $client_policy_data = $clientPolicyModel->getPolicyDetailsForRemainder(); - $myLogger->logme('error', 'Fetched client policy data'); + + $client_policy_data = $clientPolicyModel->getPolicyDetailsForEnrollment(); + $myLogger->logme('error', 'Fetched client policy data for Enrollment Status update'); // dd($client_policy_data); - $currentDate = date('d'); - // $myLogger->logme('error', 'Current date: ' . $currentDate); + $currentDate = date('d-m-Y'); + $openEnrollment = []; + $closeEnrollment = []; // Update policy status based on start and end dates foreach ($client_policy_data as $client_policy) { $id = $client_policy['id']; - $openDate = date('d', strtotime($client_policy['open_date'])); - $closeDate = date('d', strtotime($client_policy['close_date'])); - - // $myLogger->logme('error', 'Processing client policy ID: ' . $id); - // $myLogger->logme('error', 'Open date: ' . $openDate . ', Close date: ' . $closeDate); - + $openDate = date('d-m-Y', strtotime($client_policy['open_date'])); + $closeDate = date('d-m-Y', strtotime($client_policy['close_date'])); + if ($currentDate == $openDate) { $clientPolicyModel->update($id, ['open_for_enrollment' => 1]); + $openEnrollment[] = $id; $myLogger->logme('error', 'Updated policy ID ' . $id . ' to open for enrollment.'); } if ($closeDate < $currentDate) { $clientPolicyModel->update($id, ['open_for_enrollment' => 0]); + $closeEnrollment[] = $id; $myLogger->logme('error', 'Updated policy ID ' . $id . ' to close for enrollment.'); } } + + $myLogger->logme('error', 'enrollment_status function completed'); + return $this->respond([ + 'status' => true, + 'message' => 'updated Policy Enrollment Status', + 'open_policy_count' => count($openEnrollment), + 'close_policy_count' => count($closeEnrollment), + 'open_policy_ids' => $openEnrollment, + 'close_policy_ids' => $closeEnrollment, + ]); + + } + + public function sendCroneRemainderMail() + { + $clientPolicyModel = new ClientPolicyModel(); + $myLogger = \Config\Services::mylogger(); + + + $client_policy_data = $clientPolicyModel->getPolicyDetailsForRemainder(); + $myLogger->logme('error', 'Fetched client policy data'); + // dd($client_policy_data); // Mail send function - // $myLogger->logme('error', 'Calling sendRemainderMail function'); - if( $currentDate == date('d', strtotime($client_policy['reminder_date']))){ - $result = $this->sendRemainderMail($client_policy_data); - }else{ - $result = false; - } - - // $myLogger->logme('error', 'enrollment_status function completed'); + $result = $this->sendRemainderMail($client_policy_data, 'crone'); + + $myLogger->logme('error', 'sendCroneRemainderMail function completed'); + if($result){ return json_encode(['status' => true, 'message' => 'Mail send successfully']); }else{ return json_encode(['status' => false, 'message' => 'There is no data to send']); } } - public function featch_dashboard_data($type) { @@ -292,65 +304,133 @@ class DashboardController extends AdminController return $this->respond(['status' => true, 'data' => $data], 200); } - - public function sendRemainderMail($client_policy_data) + public function sendRemainderMail($client_policy_data, $send_mail_for_manual_or_crone = null) { // $this->myLogger->logme('error', 'sendRemainderMail function called'); + // dd($client_policy_data, $send_mail_for_manual_or_crone); + $reminder_whole_mail = []; foreach ($client_policy_data as $client_policy) { - - // Fetch client data - $client_data = $this->clientModel->find($client_policy['client_id']); - - // Fetch notification settings - $notification_data = $this->notificationModel - ->where('client_id', $client_policy['client_id']) - ->where('template_name', 'member_reminder_mail') - ->first(); - // $this->myLogger->logme('error', 'Notification data fetched: ' . json_encode($notification_data)); - - // Check if notification should be sent - if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { - $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); - - // Fetch all employees related to the client policy - $employees = $this->employeePolicyModel - ->select('employees.*') - ->join('employees', 'employee_polices.employee_id = employees.id', 'left') - ->where('employee_polices.client_policy_id', $client_policy['id']) - ->where('employees.emp_status', 'draft') - ->where('employees.is_active', 1) - ->where('employee_polices.status', 'draft') - ->where('employee_polices.is_active', 1) - ->where('employees.relationship', 'Self') - ->findAll(); - - // Process each employee - foreach ($employees as $employee) { - - if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { - $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); - - // Mail params - $params['emp_data'] = $employee; - $params['client_data'] = $client_data; - $params['notification_data'] = $notification_data; - - // Send the mail notification - $mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params); - // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); - $reminder_whole_mail[] = $mail_result; + if(empty($send_mail_for_manual_or_crone)){ + + // echo '1'; + + // Fetch client data + $client_data = $this->clientModel->find($client_policy['client_id']); + + // Fetch notification settings + $notification_data = $this->notificationModel + ->where('client_id', $client_policy['client_id']) + ->where('template_name', 'member_reminder_mail') + ->first(); + + // $this->myLogger->logme('error', 'Notification data fetched: ' . json_encode($notification_data)); + + // Check if notification should be sent + if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { + $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); + + // Fetch all employees related to the client policy + $employees = $this->employeePolicyModel + ->select('employees.*') + ->join('employees', 'employee_polices.employee_id = employees.id', 'left') + ->where('employee_polices.client_policy_id', $client_policy['id']) + ->where('employees.emp_status', 'draft') + ->where('employees.is_active', 1) + ->where('employee_polices.status', 'draft') + ->where('employee_polices.is_active', 1) + ->where('employees.relationship', 'Self') + ->findAll(); + + // Process each employee + foreach ($employees as $employee) { + + if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { + $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); + + // Mail params + $params['emp_data'] = $employee; + $params['client_data'] = $client_data; + $params['notification_data'] = $notification_data; + + // Send the mail notification + $mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params); + // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); + $reminder_whole_mail[] = $mail_result; + } + } + } else { + $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); + } + + } else { + + // echo '2'; + + $currentDate = date('d-m-Y'); + + if($currentDate == date('d-m-Y', strtotime($client_policy['reminder_date']))){ + + // echo '3'; + + $client_data = $this->clientModel->find($client_policy['client_id']); + + // Fetch notification settings + $notification_data = $this->notificationModel + ->where('client_id', $client_policy['client_id']) + ->where('template_name', 'member_reminder_mail') + ->first(); + + // Check if notification should be sent + if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { + + // echo '4'; + + $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); + + // Fetch all employees related to the client policy + $employees = $this->employeePolicyModel + ->select('employees.*') + ->join('employees', 'employee_polices.employee_id = employees.id', 'left') + ->where('employee_polices.client_policy_id', $client_policy['id']) + ->where('employees.emp_status', 'draft') + ->where('employees.is_active', 1) + ->where('employee_polices.status', 'draft') + ->where('employee_polices.is_active', 1) + ->where('employees.relationship', 'Self') + ->findAll(); + + // Process each employee + foreach ($employees as $employee) { + + if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { + $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); + + // Mail params + $params['emp_data'] = $employee; + $params['client_data'] = $client_data; + $params['notification_data'] = $notification_data; + + // Send the mail notification + $mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params); + // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); + $reminder_whole_mail[] = $mail_result; + } + } + } else { + // echo '5'; + $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); } } - } else { - $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); } } - $this->myLogger->logme('error', 'Whole email, count: ' . $reminder_whole_mail); + // dd($reminder_whole_mail); + + // $this->myLogger->logme('error', 'Whole email, count: ' . $reminder_whole_mail); // Process and queue bulk emails $temp_whole_data = []; @@ -387,7 +467,6 @@ class DashboardController extends AdminController } - public function sendManualRemainder($client_id, $client_branch_id) { $this->myLogger->logme('error', "sendManualRemainder called with client_id: {$client_id}, client_branch_id: {$client_branch_id}"); @@ -414,7 +493,6 @@ class DashboardController extends AdminController return $this->respond(['status' => false, 'code' => 200, 'message' => 'There is no data to send', 'message2' => 'No policy data found to send'], 200); } } - - + } diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 2802701a..b0ae954c 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -50,9 +50,12 @@ class sendMailNotification $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_data['client_name'], $mail_content); $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content); + $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); if ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) { if(isset($emp_data['relationship'])){ diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 470bbb0a..fa43886a 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -404,9 +404,24 @@ public function getPolicyDetailsForRemainder($client_id = null, $branch_id = nul } return $builder->get()->getResultArray(); +} +//for this using in CRONE JOB +public function getPolicyDetailsForEnrollment($client_id = null, $branch_id = null) +{ + $builder = $this->table('client_policy') + ->where('client_policy.is_active', 1) + ->where('client_policy.policy_status', 1) + ->where('client_policy.open_date IS NOT NULL') + ->where('client_policy.close_date IS NOT NULL'); + if ($client_id && $branch_id) { + $builder->where('client_policy.client_id', $client_id) + ->where('client_policy.client_branch_id', $branch_id); } + return $builder->get()->getResultArray(); +} + } From 18f449ecce04ba2b8d31a4e0161d328325c6f00f Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 14 Oct 2024 11:17:12 +0530 Subject: [PATCH 05/10] FEAT_TESTING_CLIENT_NOTIFICATION_MAIL_FUNCTION_AND_OTHERS : RV --- app/Config/Routes.php | 5 +- app/Controllers/NotificationController.php | 41 +- app/Helpers/sendMailNotification.php | 551 +++++++++++++++++++++ app/Models/ClientModel.php | 1 + app/Views/notification.php | 231 ++++++++- 5 files changed, 803 insertions(+), 26 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6269cfd1..58ba30e4 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -12,9 +12,9 @@ $routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']); // Reminder Mail Notification $routes->get("reminder_mail", "NotificationController::reminder_mail"); -// $routes->get("testing", "ClientController::Testing"); +$routes->get("testing", "ClientController::Testing"); // $routes->get("testing", "DashboardController::updatePolicyEnrollmentStatus"); -$routes->get("testing", "DashboardController::sendCroneRemainderMail"); +// $routes->get("testing", "DashboardController::sendCroneRemainderMail"); $routes->get("update-policy-terms-for-corrections", "ClientController::updatePolicyTermsForCorrections"); $routes->get("update_rack_rate_json", "ClientController::updateRackRateJson"); $routes->get("updatajson", "EmpDataServiceController::updatajson"); @@ -315,6 +315,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("get_client_policy_data_using_policy_no_and_endo_no/(:any)", "ClientController::get_client_policy_data_using_policy_no_and_endo_no/$1"); $routes->get("checkInvoiceStatus/(:any)", "PolicyTransactionController::checkInvoiceStatus/$1"); $routes->get("base_policy_for_policy_inception/(:any)", "PolicyTransactionController::getBasePolicy/$1"); + $routes->get("sentTestMail/(:any)", "NotificationController::sentTestMail/$1"); }); diff --git a/app/Controllers/NotificationController.php b/app/Controllers/NotificationController.php index 2c050523..ff666cef 100755 --- a/app/Controllers/NotificationController.php +++ b/app/Controllers/NotificationController.php @@ -18,18 +18,20 @@ use App\Models\EmployeeModel; use App\Models\UserModel; use App\Helpers\sendMailNotification; - +use App\Helpers\MailHelper; class NotificationController extends AdminController { use ResponseTrait; protected $myLogger; protected $notificationModel; + protected $clientModel; public function __construct() { $this->myLogger = \Config\Services::mylogger(); $this->notificationModel = new NotificationModel(); + $this->clientModel = new ClientModel(); } // This is for Template Name Camel Case to Snake Case for store in DB @@ -88,6 +90,8 @@ class NotificationController extends AdminController $id =$this->request->getPost('client_id'); $clientData['common_mails'] = $this->request->getPost('nhance_team_mail_ids'); $clientData['hr_mails'] = $this->request->getPost('hr_mail_id'); + $clientData['reply_to'] = $this->request->getPost('reply_to'); + $clientData['mail_domain'] = $this->request->getPost('mail_domain'); $clientModel->update($id,$clientData); foreach ($data as $key => $value) @@ -159,4 +163,39 @@ class NotificationController extends AdminController } } } + + // This function for sent a mail for testing + public function sentTestMail($template_id, $test_mail) + { + $notification_data = $this->notificationModel->where('id', $template_id)->where('enabled', 1)->first(); + $client_data = $this->clientModel->where('id', $notification_data['client_id'])->where('is_active', 1)->first(); + + if(!empty($notification_data)){ + + $params = [ + 'client_data' => $client_data, + 'notification_data' => $notification_data, + 'test_mail' => $test_mail + ]; + + $testMailData = sendMailNotification::sendMailNotificationForTesting($notification_data['template_name'], $params); + // print_r($testMailData); die; + if (!empty($testMailData)) { + + $mail_send_return1 = MailHelper::send_email($testMailData); + $this->myLogger->logme("info", $mail_send_return1); + $this->myLogger->logme("info", $mail_send_return1); + + return $this->respond(['status' => true,'code' => 200, 'respond' => json_decode($mail_send_return1)]); + + }else{ + + return $this->respond(['status' => false,'code' => 200, 'message' => 'Test Mail Data Does Not Exist']); + } + }else{ + + return $this->respond(['status' => false,'code' => 200, 'message' => 'Notification Template not enabled']); + + } + } } \ No newline at end of file diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index b0ae954c..91907824 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -689,4 +689,555 @@ class sendMailNotification } } + + 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']; + + $employee_name = 'John Doe'; + + $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_logo]]", "Client Logo", $mail_content); + $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content); + $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); + + $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); + + if ($mail != null || $mail != '') { + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; + } + + return $wholeData; + + } else if($action == 'member_reminder_mail'){ + + $notification_data = $params['notification_data']; + $client_data = $params['client_data']; + $mail = $params['test_mail']; + + $mail_content = $notification_data['mail_content']; + $subject = $notification_data['subject']; + + $nhance_logo = $_ENV['NHANCE_LOGO']; + $app_link = $_ENV['App_Url']; + + $employee_name = 'John Doe'; + + $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; + + $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); + $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content); + $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); + $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); + + if ((isset($notification_data) && $notification_data['enabled'] == 1)) { + + if (isset($mail) && !empty($mail)) { + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; + } + + } + + return $wholeData; + + + } else if($action == 'member_ecard_mail'){ + + $notification = $params['notification_data']; + $client_data = $params['client_data']; + $mail = $params['test_mail']; + + $mail_content = $notification['mail_content']; + $subject = $notification['subject']; + + $rand_string = 'HX3kUh'; + $link = generate_download_link($rand_string); + + $name = 'John Doe'; + + $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", $mail_content); + $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); + + $mail_content = str_replace("[[member_name]]", $name, $mail_content); + $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); + $mail_content = str_replace("[[post_enrollment_app_link]]", "Review Details", $mail_content); + $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $mail_content); + $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); + + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; + + 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 + ]; + + + $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_data['client_name'], $mail_content); + $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content); + $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); + + $mail_content = str_replace("[[app_link]]", "Review Details", $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 .= '

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

'; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + // Only Display SI Topup and Dependent Addon + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { + $table_content .= ''; + $table_content .= ''; + } + + $table_content .= ''; + $table_content .= ''; + + // Table body with details + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { + $table_content .= ''; + $table_content .= ''; + } + + $table_content .= ''; + $table_content .= ''; + $table_content .= '
NameRelationDate Of BirthSum InsuredPremiumGST
' . $array_list['name'] . $emp_code . '' . $array_list['relationship'] . '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '₹' . format_indian_number($array_list['basic_cover_si']) . '₹' . format_indian_number(round($array_list['premium'])) . '₹' . format_indian_number(round($array_list['gst'])) . '
'; + + // Calculate additional premium and GST if applicable + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { + $addtional_premium = $array_list['rata_premimum']; + $gst = $array_list['gst']; + + // Prepare addon summary + $addon_list_array = [ + 'policy_name' => $policy_name, + '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 .= '
'; + $table_content .= ''; + + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $table_content .= ''; + + $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $sum_total_words = numberToWords($total_addon); + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= '
Policy NameAdditional PremiumGSTTotal
' . $Addon_list[0]['policy_name'] . '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '₹' . format_indian_number($Addon_list[0]['gst']) . '₹' . format_indian_number($total_addon) . '
Total₹' . format_indian_number($total_addon) . '
'; + } + } + + $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content); + $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); + + + $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_data['client_name'], $mail_content); + $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content); + $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); + + $mail_content = str_replace("[[app_link]]", "Review Details", $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 .= '

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

'; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + // Only Display SI Topup and Dependent Addon + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { + $table_content .= ''; + $table_content .= ''; + } + + $table_content .= ''; + $table_content .= ''; + + // Table body with details + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { + $table_content .= ''; + $table_content .= ''; + } + + $table_content .= ''; + $table_content .= ''; + $table_content .= '
NameRelationDate Of BirthSum InsuredPremiumGST
' . $array_list['name'] . $emp_code . '' . $array_list['relationship'] . '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '₹' . format_indian_number($array_list['basic_cover_si']) . '₹' . format_indian_number(round($array_list['premium'])) . '₹' . format_indian_number(round($array_list['gst'])) . '
'; + + // Calculate additional premium and GST if applicable + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { + $addtional_premium = $array_list['rata_premimum']; + $gst = $array_list['gst']; + + // Prepare addon summary + $addon_list_array = [ + 'policy_name' => $policy_name, + '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 .= '
'; + $table_content .= ''; + + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $table_content .= ''; + + $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $sum_total_words = numberToWords($total_addon); + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= '
Policy NameAdditional PremiumGSTTotal
' . $Addon_list[0]['policy_name'] . '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '₹' . format_indian_number($Addon_list[0]['gst']) . '₹' . format_indian_number($total_addon) . '
Total₹' . format_indian_number($total_addon) . '
'; + } + } + + $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content); + $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); + + $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' => '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['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", $mail_content); + $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); + $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); + + $mail_content = str_replace("[[app_link]]", "Review Details", $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 .= '

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

'; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + // Only Display SI Topup and Dependent Addon + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { + $table_content .= ''; + $table_content .= ''; + } + + $table_content .= ''; + $table_content .= ''; + + // Table body with details + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { + $table_content .= ''; + $table_content .= ''; + } + + $table_content .= ''; + $table_content .= ''; + $table_content .= '
NameRelationDate Of BirthSum InsuredPremiumGST
' . $array_list['name'] . $emp_code . '' . $array_list['relationship'] . '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '₹' . format_indian_number($array_list['basic_cover_si']) . '₹' . format_indian_number(round($array_list['premium'])) . '₹' . format_indian_number(round($array_list['gst'])) . '
'; + + // Calculate additional premium and GST if applicable + if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { + $addtional_premium = $array_list['rata_premimum']; + $gst = $array_list['gst']; + + // Prepare addon summary + $addon_list_array = [ + 'policy_name' => $policy_name, + '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 .= '
'; + $table_content .= ''; + + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $table_content .= ''; + + $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $sum_total_words = numberToWords($total_addon); + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= '
Policy NameAdditional PremiumGSTTotal
' . $Addon_list[0]['policy_name'] . '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '₹' . format_indian_number($Addon_list[0]['gst']) . '₹' . format_indian_number($total_addon) . '
Total₹' . format_indian_number($total_addon) . '
'; + } + } + + $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content); + $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); + + + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; + + return $wholeData; + } + + } + } } \ No newline at end of file diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index 4e05f84a..e188b5bd 100755 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -38,6 +38,7 @@ class ClientModel extends Model "phone", "email", "reply_to", + "mail_domain", ]; diff --git a/app/Views/notification.php b/app/Views/notification.php index 09c95038..6b15116a 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -5,6 +5,10 @@ .preview_button{ display:none; } + + .scrollb { + overflow-y: auto !important; + }
@@ -56,16 +60,29 @@ ?>

+
- +
- +
+ +
+
+ + +
+
+ + +
+
+
@@ -156,6 +173,7 @@
+
@@ -176,7 +194,7 @@