CHANGE_UPDATE_ENROLLMENT_STATUS_FUNCTION AND_SEND_CRONE_MAIL_FUNCTION_FOR_REMAINDER_MAIL : RV
This commit is contained in:
parent
b371c2a941
commit
4a13d7c721
@ -12,7 +12,9 @@ $routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']);
|
|||||||
// Reminder Mail Notification
|
// Reminder Mail Notification
|
||||||
|
|
||||||
$routes->get("reminder_mail", "NotificationController::reminder_mail");
|
$routes->get("reminder_mail", "NotificationController::reminder_mail");
|
||||||
$routes->get("testing", "ClientController::Testing");
|
// $routes->get("testing", "ClientController::Testing");
|
||||||
|
// $routes->get("testing", "DashboardController::updatePolicyEnrollmentStatus");
|
||||||
|
$routes->get("testing", "DashboardController::sendCroneRemainderMail");
|
||||||
$routes->get("update-policy-terms-for-corrections", "ClientController::updatePolicyTermsForCorrections");
|
$routes->get("update-policy-terms-for-corrections", "ClientController::updatePolicyTermsForCorrections");
|
||||||
$routes->get("update_rack_rate_json", "ClientController::updateRackRateJson");
|
$routes->get("update_rack_rate_json", "ClientController::updateRackRateJson");
|
||||||
$routes->get("updatajson", "EmpDataServiceController::updatajson");
|
$routes->get("updatajson", "EmpDataServiceController::updatajson");
|
||||||
@ -284,6 +286,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->get("get_policy_type_for_base_policy/(:any)", "ClientController::getPolicyTypeForBasePolicy/$1");
|
$routes->get("get_policy_type_for_base_policy/(:any)", "ClientController::getPolicyTypeForBasePolicy/$1");
|
||||||
$routes->get("get_client_details/(:any)", "ClientController::getClientDetails/$1");
|
$routes->get("get_client_details/(:any)", "ClientController::getClientDetails/$1");
|
||||||
$routes->get("featch_dashboard_data/(:any)", "DashboardController::featch_dashboard_data/$1");
|
$routes->get("featch_dashboard_data/(:any)", "DashboardController::featch_dashboard_data/$1");
|
||||||
|
$routes->get("send_manual_remainder/(:any)", "DashboardController::sendManualRemainder/$1");
|
||||||
$routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1");
|
$routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1");
|
||||||
$routes->get("rename_rack_rate_tab/(:any)", "ClientController::renameRackRateTab/$1");
|
$routes->get("rename_rack_rate_tab/(:any)", "ClientController::renameRackRateTab/$1");
|
||||||
$routes->post("create_excel_template", "MasterController::createExcelTemplate");
|
$routes->post("create_excel_template", "MasterController::createExcelTemplate");
|
||||||
@ -363,6 +366,8 @@ $routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken'
|
|||||||
$routes->cli('cli/send_mail_cli(/:any)?', 'MasterController::testGmailAPIViaCLI$1');
|
$routes->cli('cli/send_mail_cli(/:any)?', 'MasterController::testGmailAPIViaCLI$1');
|
||||||
$routes->cli('cli/app_check_list', 'MasterController::appCheckList');
|
$routes->cli('cli/app_check_list', 'MasterController::appCheckList');
|
||||||
$routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken');
|
$routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken');
|
||||||
|
$routes->cli('cli/updatePolicyEnrollmentStatus', 'DashboardController::updatePolicyEnrollmentStatus');
|
||||||
|
$routes->cli('cli/sendCroneRemainderMail', 'DashboardController::sendCroneRemainderMail');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -202,52 +202,65 @@ class DashboardController extends AdminController
|
|||||||
|
|
||||||
public function updatePolicyEnrollmentStatus()
|
public function updatePolicyEnrollmentStatus()
|
||||||
{
|
{
|
||||||
$clientModel = new ClientModel();
|
|
||||||
$clientPolicyModel = new ClientPolicyModel();
|
$clientPolicyModel = new ClientPolicyModel();
|
||||||
$notificationModel = new NotificationModel();
|
|
||||||
$employeePolicyModel = new EmployeePolicyModel();
|
|
||||||
$myLogger = \Config\Services::mylogger();
|
$myLogger = \Config\Services::mylogger();
|
||||||
|
|
||||||
// $myLogger->logme('error', 'enrollment_status function called');
|
$client_policy_data = $clientPolicyModel->getPolicyDetailsForEnrollment();
|
||||||
|
$myLogger->logme('error', 'Fetched client policy data for Enrollment Status update');
|
||||||
$client_policy_data = $clientPolicyModel->getPolicyDetailsForRemainder();
|
|
||||||
$myLogger->logme('error', 'Fetched client policy data');
|
|
||||||
|
|
||||||
// dd($client_policy_data);
|
// dd($client_policy_data);
|
||||||
|
|
||||||
$currentDate = date('d');
|
$currentDate = date('d-m-Y');
|
||||||
// $myLogger->logme('error', 'Current date: ' . $currentDate);
|
$openEnrollment = [];
|
||||||
|
$closeEnrollment = [];
|
||||||
|
|
||||||
// Update policy status based on start and end dates
|
// Update policy status based on start and end dates
|
||||||
foreach ($client_policy_data as $client_policy) {
|
foreach ($client_policy_data as $client_policy) {
|
||||||
|
|
||||||
$id = $client_policy['id'];
|
$id = $client_policy['id'];
|
||||||
$openDate = date('d', strtotime($client_policy['open_date']));
|
$openDate = date('d-m-Y', strtotime($client_policy['open_date']));
|
||||||
$closeDate = date('d', strtotime($client_policy['close_date']));
|
$closeDate = date('d-m-Y', strtotime($client_policy['close_date']));
|
||||||
|
|
||||||
// $myLogger->logme('error', 'Processing client policy ID: ' . $id);
|
|
||||||
// $myLogger->logme('error', 'Open date: ' . $openDate . ', Close date: ' . $closeDate);
|
|
||||||
|
|
||||||
if ($currentDate == $openDate) {
|
if ($currentDate == $openDate) {
|
||||||
$clientPolicyModel->update($id, ['open_for_enrollment' => 1]);
|
$clientPolicyModel->update($id, ['open_for_enrollment' => 1]);
|
||||||
|
$openEnrollment[] = $id;
|
||||||
$myLogger->logme('error', 'Updated policy ID ' . $id . ' to open for enrollment.');
|
$myLogger->logme('error', 'Updated policy ID ' . $id . ' to open for enrollment.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($closeDate < $currentDate) {
|
if ($closeDate < $currentDate) {
|
||||||
$clientPolicyModel->update($id, ['open_for_enrollment' => 0]);
|
$clientPolicyModel->update($id, ['open_for_enrollment' => 0]);
|
||||||
|
$closeEnrollment[] = $id;
|
||||||
$myLogger->logme('error', 'Updated policy ID ' . $id . ' to close for enrollment.');
|
$myLogger->logme('error', 'Updated policy ID ' . $id . ' to close for enrollment.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mail send function
|
$myLogger->logme('error', 'enrollment_status function completed');
|
||||||
// $myLogger->logme('error', 'Calling sendRemainderMail function');
|
return $this->respond([
|
||||||
if( $currentDate == date('d', strtotime($client_policy['reminder_date']))){
|
'status' => true,
|
||||||
$result = $this->sendRemainderMail($client_policy_data);
|
'message' => 'updated Policy Enrollment Status',
|
||||||
}else{
|
'open_policy_count' => count($openEnrollment),
|
||||||
$result = false;
|
'close_policy_count' => count($closeEnrollment),
|
||||||
|
'open_policy_ids' => $openEnrollment,
|
||||||
|
'close_policy_ids' => $closeEnrollment,
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// $myLogger->logme('error', 'enrollment_status function completed');
|
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
|
||||||
|
$result = $this->sendRemainderMail($client_policy_data, 'crone');
|
||||||
|
|
||||||
|
$myLogger->logme('error', 'sendCroneRemainderMail function completed');
|
||||||
|
|
||||||
if($result){
|
if($result){
|
||||||
return json_encode(['status' => true, 'message' => 'Mail send successfully']);
|
return json_encode(['status' => true, 'message' => 'Mail send successfully']);
|
||||||
}else{
|
}else{
|
||||||
@ -255,7 +268,6 @@ class DashboardController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function featch_dashboard_data($type)
|
public function featch_dashboard_data($type)
|
||||||
{
|
{
|
||||||
$pendingActionsController = new PendingActionsController;
|
$pendingActionsController = new PendingActionsController;
|
||||||
@ -292,15 +304,20 @@ class DashboardController extends AdminController
|
|||||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sendRemainderMail($client_policy_data, $send_mail_for_manual_or_crone = null)
|
||||||
public function sendRemainderMail($client_policy_data)
|
|
||||||
{
|
{
|
||||||
// $this->myLogger->logme('error', 'sendRemainderMail function called');
|
// $this->myLogger->logme('error', 'sendRemainderMail function called');
|
||||||
|
|
||||||
|
// dd($client_policy_data, $send_mail_for_manual_or_crone);
|
||||||
|
|
||||||
$reminder_whole_mail = [];
|
$reminder_whole_mail = [];
|
||||||
|
|
||||||
foreach ($client_policy_data as $client_policy) {
|
foreach ($client_policy_data as $client_policy) {
|
||||||
|
|
||||||
|
if(empty($send_mail_for_manual_or_crone)){
|
||||||
|
|
||||||
|
// echo '1';
|
||||||
|
|
||||||
// Fetch client data
|
// Fetch client data
|
||||||
$client_data = $this->clientModel->find($client_policy['client_id']);
|
$client_data = $this->clientModel->find($client_policy['client_id']);
|
||||||
|
|
||||||
@ -348,9 +365,72 @@ class DashboardController extends AdminController
|
|||||||
} else {
|
} else {
|
||||||
$this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']);
|
$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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$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
|
// Process and queue bulk emails
|
||||||
$temp_whole_data = [];
|
$temp_whole_data = [];
|
||||||
@ -387,7 +467,6 @@ class DashboardController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function sendManualRemainder($client_id, $client_branch_id)
|
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}");
|
$this->myLogger->logme('error', "sendManualRemainder called with client_id: {$client_id}, client_branch_id: {$client_branch_id}");
|
||||||
@ -416,5 +495,4 @@ class DashboardController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,9 +50,12 @@ class sendMailNotification
|
|||||||
$app_link = $_ENV['App_Url'];
|
$app_link = $_ENV['App_Url'];
|
||||||
$mail_content = $notification_data['mail_content'];
|
$mail_content = $notification_data['mail_content'];
|
||||||
$nhance_logo = $_ENV['NHANCE_LOGO'];
|
$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("[[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("[[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);
|
$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 ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) {
|
||||||
if(isset($emp_data['relationship'])){
|
if(isset($emp_data['relationship'])){
|
||||||
|
|||||||
@ -404,9 +404,24 @@ public function getPolicyDetailsForRemainder($client_id = null, $branch_id = nul
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $builder->get()->getResultArray();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user