MERGE_TEST_LIVE_CHGREQ

This commit is contained in:
Venba 2024-10-14 12:28:41 +00:00
commit 6090204d60
11 changed files with 1159 additions and 193 deletions

View File

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

View File

@ -439,6 +439,29 @@ class EmployeeRestController extends AdminController
try {
$requestData = $this->request->getJSON();
foreach ($requestData as $key => $value)
{
$checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id)
->where('client_policy_id', $value->client_policy_id)
->where('is_active', 1 )
->findAll();
if ($checkIfExist) {
$empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si);
}else{
$data['employee_id']= $value->employee_id;
$data['client_policy_id']= $value->client_policy_id;
$data['basic_cover_si']= $value->basic_cover_si;
$data['status'] = 'draft';
$this->employeePolicyModel->insert($data);
}
}
if(count($requestData))
{
$this->updatePremiumAmount($requestData[0]->client_policy_id , $requestData[0]->emp_code , $requestData[0]->client_branch_id);
@ -999,7 +1022,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 +1079,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 +1088,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 +1188,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 +1284,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 +1391,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 +1524,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'))
@ -1553,6 +1575,7 @@ class EmployeeRestController extends AdminController
$responce['OpenForEnrollment'] = $array['open_for_enrollment'];
$responce['policy_terms'] = $decodedArray;
$responce['policy_type_id'] = $array['policy_type_id'];
$responce['disclaimer'] = $array['disclaimer'];
$tpaArray = $this->employeeModel->select('employees.name as name , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string')
->join('employee_polices', 'employee_polices.employee_id = employees.id')
@ -1586,8 +1609,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;
});

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

@ -19,7 +19,7 @@ class CloseDbConnection implements FilterInterface
// Get all database configurations
$db = \Config\Database::connect();
$log = \Config\Services::mylogger();
$log->logme('error','CloseDbConnections....!');
// $log->logme('error','CloseDbConnections....!');
$db->close();
}
}

View File

@ -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, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc);
if($res['status'])
{

View File

@ -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]]", "<a href='$app_link'>Review Details</a>", $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'];
@ -46,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]]", "<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 ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) {
if(isset($emp_data['relationship'])){
@ -72,9 +79,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 +105,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 +113,13 @@ class sendMailNotification
if (count($wholeData) < 1) {
$wholeData = [];
}
return $wholeData;
// }else{
// return "false";
// }
} else if($action == 'member_ecard_mail'){
$notification = $params['notification'];
@ -144,9 +156,10 @@ class sendMailNotification
// $mail_content = str_replace("[[tpa_id]]", $tpa_id, $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']];
$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
@ -189,64 +202,66 @@ class sendMailNotification
foreach ($array_list as $item) {
if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px; ">';
$table_content .= '<div style="text-align:left;"><h4 style="font-size: 12px; ">Policy Name : ';
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Name : ';
$temp_data = '';
$policy_name = '';
$is_addon = '';
foreach ($item as $inner_item) {
$policy_name = $inner_item['policy_name'];
$temp_data .= '<tr style="font-size: 12px; ">';
$temp_data .= '<td>' . $inner_item['name'] . '</td>';
if ($inner_item['relationship'] == 'Self') {
$emp_code = ' (' . $inner_item['emp_code'] . ')';
} else {
$emp_code = '';
}
$temp_data .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
$temp_data .= '<td>₹' . format_indian_number($inner_item['basic_cover_si']) . '</td>';
//Only Display SI Topup and Dependent Addon
// Only Display SI Topup and Dependent Addon
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['premium'])) . '</td>';
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['gst'])) . '</td>';
}
$temp_data .= '</tr>';
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 . '</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;">';
// Add text-align: center to the table head
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>';
//Only Display SI Topup and Dependent Addon
// Only Display SI Topup and Dependent Addon
if ($is_addon == 2 || $is_addon == 3) {
$table_content .= '<th>Premium</th>';
$table_content .= '<th>GST</th>';
}
$table_content .= '</tr>';
$table_content .= '</thead>';
$table_content .= '<tbody>' . $temp_data . '</tbody>';
// Add text-align: center to the table body
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
$table_content .= '</table></div>';
if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [
'policy_name' => $policy_name,
@ -255,36 +270,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 .= '<br><div style="text-align: left; font-size: 12px; ">';
$table_content .= '<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;">';
$table_content .= '<tr style="font-size: 12px;" ><th>Policy Name</th><th>Additional Premium</th><th>GST</th><th>Total</th></tr>';
$table_content .= '</thead><tbody>';
$sum_tolal = 0;
if (count($Addon_list) > 0) {
$table_content .= '<br><div style="text-align: left; font-size: 12px;"><div style="text-align:left;">';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
// Center align for table header and body
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Policy Name</th>';
$table_content .= '<th>Additional Premium</th>';
$table_content .= '<th>GST</th>';
$table_content .= '<th>Total</th>';
$table_content .= '</tr>';
$table_content .= '</thead>';
$table_content .= '<tbody style="text-align: center;">';
$sum_total = 0;
foreach ($Addon_list as $key => $value) {
$sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
$table_content .= '<tr style="font-size: 12px; "><td>' . $value['policy_name'] . '</td>';
$total_addon = $value['gst'] + $value['addtional_premium'];
$sum_total += $total_addon;
$table_content .= '<tr>';
$table_content .= '<td>' . $value['policy_name'] . '</td>';
$table_content .= '<td>₹' . format_indian_number($value['addtional_premium']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($value['gst']) . '</td>';
$table_content .= '<td>₹' . format_indian_number(($value['gst'] + $value['addtional_premium'])) . '</td></tr>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>';
}
$sum_total_words = numberToWords($sum_tolal);
$table_content .= '<tr style="font-size: 12px;"><td></td><td></td><td><b>Total</b></td><td>₹' . format_indian_number($sum_tolal) . '</td></tr>';
$table_content .= '</tbody></table></div></div>';
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px; ">' . $sum_total_words . '</div>';
$sum_total_words = numberToWords($sum_total);
$table_content .= '<tr>';
$table_content .= '<td></td><td></td><td><b>Total</b></td>';
$table_content .= '<td>₹' . format_indian_number($sum_total) . '</td>';
$table_content .= '</tr>';
$table_content .= '</tbody>';
$table_content .= '</table></div></div>';
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
}
// print_r($table_content); die;
@ -296,7 +327,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;
@ -349,7 +380,6 @@ class sendMailNotification
$Addon_list = [];
foreach ($array_list as $item) {
if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Name : ';
$temp_data = '';
@ -364,19 +394,19 @@ class sendMailNotification
} else {
$emp_code = '';
}
$temp_data .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
$temp_data .= '<td>₹' . format_indian_number($inner_item['basic_cover_si']) . '</td>';
//Only Display SI Topup and Dependent Addon
// Only Display SI Topup and Dependent Addon
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['premium'])) . '</td>';
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['gst'])) . '</td>';
}
$temp_data .= '</tr>';
$is_addon = $inner_item['is_addon'];
@ -389,22 +419,26 @@ class sendMailNotification
$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;">';
// Add text-align: center to the table head
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>';
//Only Display SI Topup and Dependent Addon
// Only Display SI Topup and Dependent Addon
if ($is_addon == 2 || $is_addon == 3) {
$table_content .= '<th>Premium</th>';
$table_content .= '<th>GST</th>';
}
$table_content .= '</tr>';
$table_content .= '</thead>';
$table_content .= '<tbody>' . $temp_data . '</tbody>';
// Add text-align: center to the table body
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
$table_content .= '</table></div>';
if ($is_addon == 2 || $is_addon == 3) {
@ -425,7 +459,9 @@ class sendMailNotification
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;">';
// Center align for table header and body
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Policy Name</th>';
$table_content .= '<th>Additional Premium</th>';
@ -433,8 +469,9 @@ class sendMailNotification
$table_content .= '<th>Total</th>';
$table_content .= '</tr>';
$table_content .= '</thead>';
$table_content .= '<tbody>';
$table_content .= '<tbody style="text-align: center;">';
$sum_total = 0;
foreach ($Addon_list as $key => $value) {
$total_addon = $value['gst'] + $value['addtional_premium'];
@ -457,6 +494,7 @@ class sendMailNotification
$table_content .= '</table></div></div>';
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
}
$mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
@ -466,7 +504,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;
@ -519,7 +557,6 @@ class sendMailNotification
$Addon_list = [];
foreach ($array_list as $item) {
if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Name : ';
$temp_data = '';
@ -534,19 +571,19 @@ class sendMailNotification
} else {
$emp_code = '';
}
$temp_data .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
$temp_data .= '<td>₹' . format_indian_number($inner_item['basic_cover_si']) . '</td>';
//Only Display SI Topup and Dependent Addon
// Only Display SI Topup and Dependent Addon
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['premium'])) . '</td>';
$temp_data .= '<td>₹' . format_indian_number(round($inner_item['gst'])) . '</td>';
}
$temp_data .= '</tr>';
$is_addon = $inner_item['is_addon'];
@ -559,22 +596,26 @@ class sendMailNotification
$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;">';
// Add text-align: center to the table head
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>';
//Only Display SI Topup and Dependent Addon
// Only Display SI Topup and Dependent Addon
if ($is_addon == 2 || $is_addon == 3) {
$table_content .= '<th>Premium</th>';
$table_content .= '<th>GST</th>';
}
$table_content .= '</tr>';
$table_content .= '</thead>';
$table_content .= '<tbody>' . $temp_data . '</tbody>';
// Add text-align: center to the table body
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
$table_content .= '</table></div>';
if ($is_addon == 2 || $is_addon == 3) {
@ -595,7 +636,9 @@ class sendMailNotification
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;">';
// Center align for table header and body
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Policy Name</th>';
$table_content .= '<th>Additional Premium</th>';
@ -603,8 +646,9 @@ class sendMailNotification
$table_content .= '<th>Total</th>';
$table_content .= '</tr>';
$table_content .= '</thead>';
$table_content .= '<tbody>';
$table_content .= '<tbody style="text-align: center;">';
$sum_total = 0;
foreach ($Addon_list as $key => $value) {
$total_addon = $value['gst'] + $value['addtional_premium'];
@ -627,7 +671,7 @@ class sendMailNotification
$table_content .= '</table></div></div>';
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
}
$mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
@ -636,7 +680,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']];
}
@ -645,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

@ -37,6 +37,8 @@ class ClientModel extends Model
"reference",
"phone",
"email",
"reply_to",
"mail_domain",
];

View File

@ -49,6 +49,7 @@ class ClientPolicyModel extends Model
"cd_ac_no",
"gst",
"enrolment_visibility",
"disclaimer",
"is_active",
];
@ -404,9 +405,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();
}
}

View File

@ -161,7 +161,7 @@ class EmployeeModel extends Model
// for EMP rest API process do not change
public function checkExistingEmployee($arr,$client_branch_id)
{
return $this->where('emp_code',$arr['emp_code'])->where('name',$arr['name'])->where('client_id', $arr['client_id'])->where('client_branch_id', $client_branch_id)->first();
return $this->where('emp_code',$arr['emp_code'])->where('name',$arr['name'])->where('client_id', $arr['client_id'])->where('client_branch_id', $client_branch_id)->where('emp_status !=', 'truncated')->first();
}

View File

@ -128,7 +128,6 @@
</select>
</div>
<div class="form-group col-md-4">
<label for="mobile">GST ( % )<span id="tpa_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="GST (%)" id="gst_no" name="gst" required>
@ -143,18 +142,27 @@
<label for="inception_type" style="position: relative;bottom: 5px;left: 85px;">Enable
Employee Enrolment Process</label>
</div>
<div class="form-group col-md-4">
<label for="open_date">Open Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control dateofdata" placeholder="Enter Open Date " name="open_date" id="open_date" >
</div>
<div class="form-group col-md-4">
<label for="close_date">Close Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control dateofdata" placeholder="Enter Close Date " name="close_date" id="close_date" >
</div>
<div class="form-group col-md-4">
<label for="reminder_date">Reminder Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control dateofdata" placeholder="Enter Reminder Date " name="reminder_date" id="reminder_date" >
</div>
<div class="form-group col-md-12">
<label for="disclaimer">Disclaimer<span class="text-danger">*</span></label>
<textarea class="form-control" placeholder="Enter Disclaimer" name="disclaimer" id="disclaimer" ></textarea>
</div>
<div class="form-group col-md-4">
<label class="switch" style="position: relative;top: 43px;left: 20px;">
<input id="policy_visibility" type="checkbox" name="enrolment_visibility" checked>
@ -743,6 +751,7 @@
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
$('#close_date').val(rearrangeDateFormat(res.data.close_date));
$('#reminder_date').val(rearrangeDateFormat(res.data.reminder_date));
$('#disclaimer').val(res.data.disclaimer);
$('#gst_no').val(gst);
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
$('#policy_status_field').show();

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>