FEAT_TESTING_CLIENT_NOTIFICATION_MAIL_FUNCTION_AND_OTHERS : RV

This commit is contained in:
VENKATESHWARAN 2024-10-14 11:17:12 +05:30
parent 4a13d7c721
commit 18f449ecce
5 changed files with 803 additions and 26 deletions

View File

@ -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");
});

View File

@ -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']);
}
}
}

View File

@ -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]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $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]]", "<a href='$app_link'>Review Details</a>", $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]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $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]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[member_name]]", $name, $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
$mail_content = str_replace("[[post_enrollment_app_link]]", "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content);
$mail_content = str_replace("[[ecard_download_link]]", "<a href='$link/1'>Download Insurance Card</a>", $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]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
// Step 1: Replace the placeholder with an HTML table structure
$table_content = '';
$addtional_premium = 0;
$gst = 0;
$Addon_list = [];
$name = $array_list['name'];
$emp_code = '';
if (!empty($array_list)) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy 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 . '</h4></div>';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>';
// Only Display SI Topup and Dependent Addon
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<th>Premium</th>';
$table_content .= '<th>GST</th>';
}
$table_content .= '</tr>';
$table_content .= '</thead>';
// Table body with details
$table_content .= '<tbody style="text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<td>' . $array_list['name'] . $emp_code . '</td>';
$table_content .= '<td>' . $array_list['relationship'] . '</td>';
$table_content .= '<td>' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>';
$table_content .= '<td>₹' . format_indian_number($array_list['basic_cover_si']) . '</td>';
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<td>₹' . format_indian_number(round($array_list['premium'])) . '</td>';
$table_content .= '<td>₹' . format_indian_number(round($array_list['gst'])) . '</td>';
}
$table_content .= '</tr>';
$table_content .= '</tbody>';
$table_content .= '</table></div>';
// Calculate additional premium and GST if applicable
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$addtional_premium = $array_list['rata_premimum'];
$gst = $array_list['gst'];
// Prepare addon summary
$addon_list_array = [
'policy_name' => $policy_name,
'addtional_premium' => round($addtional_premium),
'gst' => round($gst)
];
$Addon_list[] = $addon_list_array;
}
// Generate summary table for addon if applicable
if (count($Addon_list) > 0) {
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Policy Name</th>';
$table_content .= '<th>Additional Premium</th>';
$table_content .= '<th>GST</th>';
$table_content .= '<th>Total</th>';
$table_content .= '</tr>';
$table_content .= '</thead>';
$table_content .= '<tbody style="text-align: center;">';
$total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
$table_content .= '<tr>';
$table_content .= '<td>' . $Addon_list[0]['policy_name'] . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['gst']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>';
$sum_total_words = numberToWords($total_addon);
$table_content .= '<tr>';
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>';
$table_content .= '</tbody>';
$table_content .= '</table></div></div>';
}
}
$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]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
// Step 1: Replace the placeholder with an HTML table structure
$table_content = '';
$addtional_premium = 0;
$gst = 0;
$Addon_list = [];
$name = $array_list['name'];
$emp_code = '';
if (!empty($array_list)) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy 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 . '</h4></div>';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>';
// Only Display SI Topup and Dependent Addon
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<th>Premium</th>';
$table_content .= '<th>GST</th>';
}
$table_content .= '</tr>';
$table_content .= '</thead>';
// Table body with details
$table_content .= '<tbody style="text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<td>' . $array_list['name'] . $emp_code . '</td>';
$table_content .= '<td>' . $array_list['relationship'] . '</td>';
$table_content .= '<td>' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>';
$table_content .= '<td>₹' . format_indian_number($array_list['basic_cover_si']) . '</td>';
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<td>₹' . format_indian_number(round($array_list['premium'])) . '</td>';
$table_content .= '<td>₹' . format_indian_number(round($array_list['gst'])) . '</td>';
}
$table_content .= '</tr>';
$table_content .= '</tbody>';
$table_content .= '</table></div>';
// Calculate additional premium and GST if applicable
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$addtional_premium = $array_list['rata_premimum'];
$gst = $array_list['gst'];
// Prepare addon summary
$addon_list_array = [
'policy_name' => $policy_name,
'addtional_premium' => round($addtional_premium),
'gst' => round($gst)
];
$Addon_list[] = $addon_list_array;
}
// Generate summary table for addon if applicable
if (count($Addon_list) > 0) {
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Policy Name</th>';
$table_content .= '<th>Additional Premium</th>';
$table_content .= '<th>GST</th>';
$table_content .= '<th>Total</th>';
$table_content .= '</tr>';
$table_content .= '</thead>';
$table_content .= '<tbody style="text-align: center;">';
$total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
$table_content .= '<tr>';
$table_content .= '<td>' . $Addon_list[0]['policy_name'] . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['gst']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>';
$sum_total_words = numberToWords($total_addon);
$table_content .= '<tr>';
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>';
$table_content .= '</tbody>';
$table_content .= '</table></div></div>';
}
}
$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]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
// Step 1: Replace the placeholder with an HTML table structure
$table_content = '';
$addtional_premium = 0;
$gst = 0;
$Addon_list = [];
$name = $array_list['name'];
$emp_code = '';
if (!empty($array_list)) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy 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 . '</h4></div>';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>';
// Only Display SI Topup and Dependent Addon
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<th>Premium</th>';
$table_content .= '<th>GST</th>';
}
$table_content .= '</tr>';
$table_content .= '</thead>';
// Table body with details
$table_content .= '<tbody style="text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<td>' . $array_list['name'] . $emp_code . '</td>';
$table_content .= '<td>' . $array_list['relationship'] . '</td>';
$table_content .= '<td>' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>';
$table_content .= '<td>₹' . format_indian_number($array_list['basic_cover_si']) . '</td>';
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<td>₹' . format_indian_number(round($array_list['premium'])) . '</td>';
$table_content .= '<td>₹' . format_indian_number(round($array_list['gst'])) . '</td>';
}
$table_content .= '</tr>';
$table_content .= '</tbody>';
$table_content .= '</table></div>';
// Calculate additional premium and GST if applicable
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$addtional_premium = $array_list['rata_premimum'];
$gst = $array_list['gst'];
// Prepare addon summary
$addon_list_array = [
'policy_name' => $policy_name,
'addtional_premium' => round($addtional_premium),
'gst' => round($gst)
];
$Addon_list[] = $addon_list_array;
}
// Generate summary table for addon if applicable
if (count($Addon_list) > 0) {
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Policy Name</th>';
$table_content .= '<th>Additional Premium</th>';
$table_content .= '<th>GST</th>';
$table_content .= '<th>Total</th>';
$table_content .= '</tr>';
$table_content .= '</thead>';
$table_content .= '<tbody style="text-align: center;">';
$total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
$table_content .= '<tr>';
$table_content .= '<td>' . $Addon_list[0]['policy_name'] . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['gst']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>';
$sum_total_words = numberToWords($total_addon);
$table_content .= '<tr>';
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>';
$table_content .= '</tbody>';
$table_content .= '</table></div></div>';
}
}
$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;
}
}
}
}

View File

@ -38,6 +38,7 @@ class ClientModel extends Model
"phone",
"email",
"reply_to",
"mail_domain",
];

View File

@ -5,6 +5,10 @@
.preview_button{
display:none;
}
.scrollb {
overflow-y: auto !important;
}
</style>
<div class="tab-pane fade" id="notification-tab">
<input type="hidden" id="client_id_for_client_branch" value="<?= isset($notification['id']) ? $notification['id'] : '' ?>"/>
@ -56,16 +60,29 @@
?></p>
</div>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="branch_name">Team mail ID<span class="text-danger">*</span></label>
<label for="branch_name">Team mail ID<span class="text-danger"></span></label>
<textarea name="" id="nhance_team_mail_ids" class="form-control" placeholder="Example: jhon@gmail.com, dave@gmail.com"><?php echo isset($client['common_mails']) ? $client['common_mails'] : ''; ?></textarea>
</div>
<div class="form-group col-md-6">
<label for="branch_name">HR mail ID<span class="text-danger">*</span></label>
<label for="branch_name">HR mail ID<span class="text-danger"></span></label>
<textarea name="" id="hr_mail_id" class="form-control" placeholder="Example: jhon@gmail.com, dave@gmail.com"><?php echo isset($client['hr_mails']) ? $client['hr_mails'] : ''; ?></textarea>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="mail_domain">Mail Domain<span class="text-danger"></span></label>
<input type="text" name="" id="mail_domain" class="form-control" placeholder="Only one Domain Name. Example: nhance.com" value="<?php echo isset($client['mail_domain']) ? $client['mail_domain'] : ''; ?>">
</div>
<div class="form-group col-md-6">
<label for="reply_to">Reply To Mail<span class="text-danger"></span></label>
<input type="text" name="" id="reply_to" class="form-control" placeholder="Only one Reply-to mail. Example: jhon@gmail.com" value="<?php echo isset($client['reply_to']) ? $client['reply_to'] : ''; ?>">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="branch_name">Member welcome mail</label>
@ -156,6 +173,7 @@
<textarea style="display:none;" name="" id="" class="form-control "></textarea>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
</div>
@ -176,7 +194,7 @@
<!-- Modal content for the Large example -->
<div class="modal fade" id="member_welcome_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-full-width">
<div class="modal-dialog modal-full-width scrollb" >
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myLargeModalLabel">Member welcome mail <span id="nameOfThePolicy"></span></h4>
@ -206,6 +224,9 @@
<div class="form-group col-md-5">
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
</div>
<div class="form-group col-md-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
</div>
</div>
<div class="form-row" id="rac_rate_dropdown">
@ -226,15 +247,11 @@
</div>
<input type="file" id="Question_title_fileInput" style="display: none;">
</div>
<div class="form-group text-right m-b-0">
<a class="btn btn-primary waves-effect waves-light mr-1 preview_button"
data-toggle="modal" data-target="#preview_modal" >Preview</a>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnGridSubmit_2">Submit</button>
</div>
@ -244,10 +261,8 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<div class="modal fade" id="member_reminder_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal fade" id="member_reminder_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false" aria-modal="true">
<div class="modal-dialog modal-full-width">
<div class="modal-content">
<div class="modal-header">
@ -278,6 +293,9 @@
<div class="form-group col-md-5">
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
</div>
<div class="form-group col-md-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
</div>
</div>
<!-- <div class="form-row" id="rac_rate_dropdown">
@ -329,8 +347,6 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<div class="modal fade" id="member_ecard_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
@ -364,6 +380,9 @@
<div class="form-group col-md-5">
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
</div>
<div class="form-group col-md-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
</div>
</div>
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
@ -404,7 +423,6 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<div class="modal fade" id="member_review_and_summary_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
@ -438,6 +456,9 @@
<div class="form-group col-md-5">
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
</div>
<div class="form-group col-md-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
</div>
</div>
<!-- <div class="form-row" id="rac_rate_dropdown">
@ -489,7 +510,6 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<div class="modal fade" id="account_maneger_summary_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
@ -523,6 +543,9 @@
<div class="form-group col-md-5">
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
</div>
<div class="form-group col-md-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
</div>
</div>
<!-- <div class="form-row" id="rac_rate_dropdown">
@ -574,7 +597,6 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<div class="modal fade" id="client_hr_summary_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
@ -608,6 +630,9 @@
<div class="form-group col-md-5">
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
</div>
<div class="form-group col-md-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
</div>
</div>
<!-- <div class="form-row" id="rac_rate_dropdown">
@ -661,18 +686,16 @@
<div class="modal fade" id="preview_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-full-width">
<div class="modal fade" id="preview_modal" tabindex="-1" role="dialog" aria-hidden="false" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myLargeModalLabel">Member Review and summary mail <span id="nameOfThePolicy"></span></h4>
<h4 class="modal-title" id="myLargeModalLabel">Testing Mail Data<span id="nameOfThePolicy"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="text-center" id="no_data"></div>
</div>
</div><!-- /.modal-content -->
@ -681,12 +704,51 @@
<script>
// document.addEventListener('DOMContentLoaded', function () {
// console.log('DOMContentLoaded start');
// var memberWelcomeMailModal = new bootstrap.Modal(document.getElementById('member_welcome_mail_modal'));
// var previewModal = new bootstrap.Modal(document.getElementById('preview_modal'));
// document.getElementById('preview_modal').addEventListener('hidden.bs.modal', function () {
// console.log('testing modal');
// memberWelcomeMailModal.show();
// console.log('testing modal end');
// });
// console.log('DOMContentLoaded end');
// });
$(document).on('hide.bs.modal', '.modal', function () {
console.log("Modal is hidden");
});
$(document).on('show.bs.modal', '.modal', function () {
console.log("Modal is hidden");
});
$(document).ready(function() {
console.log('document ready start');
var memberWelcomeMailModal = new bootstrap.Modal(document.getElementById('member_welcome_mail_modal'));
var previewModal = new bootstrap.Modal(document.getElementById('preview_modal'));
document.getElementById('preview_modal').addEventListener('hidden.bs.modal', function () {
console.log('testing modal');
memberWelcomeMailModal.show();
console.log('testing modal end');
});
console.log('document ready end');
var toolbar = "bold,italic,strikethrough,|,superscript,subscript,|,align,";
const editorConfig = {
buttons: toolbar,
@ -770,6 +832,7 @@
})
const fileInput = document.getElementById("Question_title_fileInput");
fileInput.addEventListener("change", () => {
const file = fileInput.files[0];
if (file)
@ -958,7 +1021,6 @@
}
})
$('#account_maneger_summary_mail_form').submit(function (event)
{
event.preventDefault();
@ -1055,6 +1117,8 @@
formData.push({name:'client_id', value: $('#general_PrimaryKey').val()})
formData.push({ name: 'nhance_team_mail_ids', value: $('#nhance_team_mail_ids').val() });
formData.push({ name: 'hr_mail_id', value: $('#hr_mail_id').val() });
formData.push({ name: 'mail_domain', value: $('#mail_domain').val() });
formData.push({ name: 'reply_to', value: $('#reply_to').val() });
formData.push({ name: 'member_welcome_mail_btn', value: $('#member_welcome_mail_btn').prop('checked') });
formData.push({ name: 'member_reminder_mail_btn', value: $('#member_reminder_mail_btn').prop('checked') });
formData.push({ name: 'member_ecard_mail_btn', value: $('#member_ecard_mail_btn').prop('checked') });
@ -1095,7 +1159,6 @@
})
});
if ($('#myDropdown')[0]) {
document.getElementById("myDropdown").addEventListener("click", function(event)
{
@ -1120,23 +1183,41 @@
function getMailTemplateData(element)
{
var template_name = $(element).attr('id');
if (template_name == "member_welcome_mail" || template_name == "member_reminder_mail" || template_name == "member_ecard_mail" || template_name == "member_review_and_summary_mail" || template_name == "account_maneger_summary_mail" || template_name == "client_hr_summary_mail")
{
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var form_action = '<?= base_url("client/notification/getMailTemplateData/") ?>'+template_name+ '/' + $('#general_PrimaryKey').val();
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
success: function(res) {
console.log(res);
console.log('get Mail Template Data', res);
if (res)
{
$(`#${template_name}_form`).find('#template_name').val(snakeCaseToCamelCase(res.template_name));
$(`#${template_name}_form`).find('#subject').val(res.subject);
$(`#${template_name}_form`).find('.jodit-wysiwyg').html(res.mail_content);
console.log(res.id)
if(res.id){
$('.testmail').show();
$('.setid').attr('data-id', res.id);
}else{
$('.testmail').hide();
$('.setid').attr('data-id', '');
}
}else{
$('.testmail').hide();
$('.setid').attr('data-id', '');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@ -1154,5 +1235,109 @@
}
}
function testMailSend(input){
// var memberWelcomeMailModal = new bootstrap.Modal(document.getElementById('member_welcome_mail_modal'));
// var previewModal = new bootstrap.Modal(document.getElementById('preview_modal'));
// previewModal.show();
// $('.close').click();
// Swal.fire({
// title: "Enter Testing mail",
// input: "text",
// inputPlaceholder: "Enter your email",
// showCancelButton: true,
// confirmButtonText: "Submit",
// backdrop: 'static', // Prevent focus issue by disallowing clicking outside
// preConfirm: (inputValue) => {
// if (!inputValue) {
// Swal.showValidationMessage('Please enter a valid email');
// }
// return inputValue;
// }
// }).then((result) => {
// if (result.isConfirmed) {
// Swal.fire({
// title: `Entered Email: ${result.value}`,
// text: 'This is the email you entered.',
// icon: 'success'
// });
// }
// });
// return false;
let test_mail = prompt("Please enter test mail:");
console.log('mail address:', test_mail);
if (test_mail !== null || test_mail !== "") {
if(isValidEmail(test_mail)){
var template_id = $(input).data('id');
console.log('templte id', template_id);
if(template_id){
let url = '<?= base_url('util/sentTestMail/') ?>' + template_id + '/' + test_mail;
console.log('testing mail url:', url);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: url,
type: "GET",
dataType: 'json',
success: function (res) {
console.log('Test mail send function response', res)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == true){
let respond = res.respond;
console.log('Parsed respond', respond)
if(respond.status == 'success'){
toastr.success(respond.message, 'SUCCESS')
}else{
toastr.warning(respond.message, 'WARNING')
}
}else{
toastr.warning('Failed to sent mail', 'WARNING')
}
},
error: function (xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error(xhr.responseText);
console.error(status, error);
}
});
}else{
let alert_msg = 'Template ID not exist'
toastr.warning(alert_msg, 'WARNING');
}
}else{
toastr.warning('Please enter the valid mail', 'WARNING');
}
}else{
toastr.warning('Please enter the valid mail', 'WARNING');
}
}
function isValidEmail(email) {
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return emailPattern.test(email);
}
</script>