diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index b701d493..a94471e9 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -138,7 +138,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
$routes->post("upload", "EmployeeController::employeesUplodWithEvents");
$routes->get("excel_error/(:any)", "EmployeeController::getExcelFileErrors/$1");
$routes->get("endorsement-list", "EmployeeController::endorsementList");
- $routes->get("enrollment-list", "EmployeeController::enrollmentClientList");
+ $routes->match(['get','post'],'enrollment-list','EmployeeController::enrollmentClientList');
$routes->get("empby_client_clientbranch/(:any)/(:any)", "EmployeeController::empby_client_clientbranch/$1/$2");
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
});
@@ -270,6 +270,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->cli('cli/processjob', 'JobWorker::processJob');
$routes->cli('cli/processjobs', 'JobWorker::processJobs');
+$routes->cli('cli/enrollment_status', 'JobWorker::enrollment_status');
$routes->get("processjob", "JobWorker::processJob");
diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php
index 788a31ca..5ffe24f3 100644
--- a/app/Controllers/ClientController.php
+++ b/app/Controllers/ClientController.php
@@ -729,7 +729,7 @@ class ClientController extends AdminController
$base_policy = $this->request->getPost('base_policy');
- $insurerValue = (string) $this->request->getPost('insurer');
+ $insurerValue = (string) $this->request->getPost('insurer');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
@@ -814,8 +814,17 @@ class ClientController extends AdminController
$data['policy_no'] = $this->request->getPost('policy_no');
- $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
- $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
+ if($data['inception_type'] == 2){
+ $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
+ $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
+ $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d');
+
+ }else{
+ $data['policy_start_date'] = null;
+ $data['policy_end_date'] = null;
+ $data['reminder_date'] = null;
+ }
+
$data['created_by'] = get_session_userid();
$insert = $this->clientPolicyModel->insert($data);
@@ -851,8 +860,8 @@ class ClientController extends AdminController
$data['tpa_id'] = $tpaId;
$data['policy_type_id'] = $this->request->getPost('policy_type_id');
$data['policy_no'] = $this->request->getPost('policy_no');
- $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
- $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
+ // $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
+ // $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
$data['insured'] = $this->request->getPost('insured');
$data['no_of_lives'] = $this->request->getPost('no_of_lives');
@@ -874,6 +883,16 @@ class ClientController extends AdminController
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst');
+ if($data['inception_type'] == 2){
+ $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
+ $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
+ $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d');
+ }else{
+ $data['policy_start_date'] = null;
+ $data['policy_end_date'] = null;
+ $data['reminder_date'] = null;
+ }
+
if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){
$data['is_addon'] = 1;
diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php
index 43ebcb94..7a29a9a3 100644
--- a/app/Controllers/DashboardController.php
+++ b/app/Controllers/DashboardController.php
@@ -35,7 +35,6 @@ class DashboardController extends AdminController
{
$data = [];
-
$results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name,
client_branch.id as client_branch_id, client_branch.branch_name,
client_branch.branch_code, employees.id as employee_id,
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 96458c17..ea0b306a 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -674,8 +674,15 @@ class EmployeeController extends AdminController
$branch_list = $this->clientBranchModel->findAll();
$data['client_list'] = $client_list;
$data['branch_list'] = $branch_list;
- $this->myLogger->logme('error', 'list called');
- $this->loadLayout('enrollment_list', $data);
+
+ // Get session data if available
+ $data['selected_client_id'] = session()->get('client_id');
+ $data['selected_branch_id'] = session()->get('branch_id');
+ $data['selected_type'] = session()->get('type');
+
+ $this->myLogger->logme('error', 'list called');
+ return $this->loadLayout('enrollment_list', $data);
+
}
public function empby_client_clientbranch($client_id, $branch_id)
@@ -718,7 +725,7 @@ class EmployeeController extends AdminController
$employeeId = $row['employee_id'];
}
-
+
return json_encode($groupedData);
}
diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php
index 38fd648a..21ba4e84 100644
--- a/app/Controllers/JobWorker.php
+++ b/app/Controllers/JobWorker.php
@@ -4,6 +4,13 @@ namespace App\Controllers;
use App\Models\JobModel;
+use App\Models\ClientModel;
+use App\Models\ClientPolicyModel;
+use App\Models\NotificationModel;
+use App\Models\EmployeePolicyModel;
+
+use App\Helpers\sendMailNotification;
+
class JobWorker extends AdminController
{
const STATUS_DONE = 'done';
@@ -228,6 +235,71 @@ class JobWorker extends AdminController
}
+ public static function enrollment_status() {
+ $clientModel = new ClientModel();
+ $clientPolicyModel = new ClientPolicyModel();
+ $notificationModel = new NotificationModel();
+ $employeePolicyModel = new EmployeePolicyModel();
+ $myLogger = \Config\Services::mylogger();
+
+ $client_policy_data = $clientPolicyModel->where('is_active', 1)
+ ->where('policy_status', 1)
+ ->where('inception_type', 2)
+ ->findAll();
+ $currentDate = date('Y-m-d');
+
+ // Update policy status based on start and end dates
+ foreach ($client_policy_data as $client_policy) {
+ $id = $client_policy['id'];
+
+ if ($currentDate == $client_policy['policy_start_date']) {
+ $clientPolicyModel->update($id, ['open_for_enrollment' => 1]);
+ }
+ if ($client_policy['policy_end_date'] < $currentDate) {
+ $clientPolicyModel->update($id, ['open_for_enrollment' => 0]);
+ }
+ }
+
+ $reminder_whole_mail = [];
+ foreach ($client_policy_data as $client_policy) {
+ $employee = $employeePolicyModel->select('employees.*')
+ ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
+ ->where('employee_polices.client_policy_id', $client_policy['id'])
+ ->first();
+ $client_data = $clientModel->find($client_policy['client_id']);
+ $notification_data = $notificationModel->where('client_id', $client_policy['client_id'])
+ ->where('template_name', 'member_reminder_mail')
+ ->first();
+
+ if ($notification_data && $notification_data['enabled'] == 1 && $currentDate == $client_policy['reminder_date']) {
+ $params['emp_data'] = $employee;
+ $params['client_data'] = $client_data;
+ $params['notification_data'] = $notification_data;
+ $reminder_whole_mail[] = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
+ }
+ }
+ // Process and queue bulk emails
+ $temp_whole_data = [];
+ $count = 0;
+ foreach ($reminder_whole_mail as $whole_index => $values) {
+ foreach ($values as $index => $value) {
+ $temp_whole_data[] = $value;
+ $count++;
+
+ if ($count == 20 || ($whole_index == count($reminder_whole_mail) - 1 && $index == count($values) - 1)) {
+ if (!empty($temp_whole_data)) {
+ Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
+ $temp_whole_data = [];
+ $count = 0;
+ }
+ }
+ }
+ }
+
+ return json_encode(true);
+ }
+
+
}
diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php
index 5a35ccd2..cd0bda80 100644
--- a/app/Helpers/sendMailNotification.php
+++ b/app/Helpers/sendMailNotification.php
@@ -12,7 +12,7 @@ class sendMailNotification
{
public static function sendMailNotification($action, $params)
{
- print_r($params);die;
+ $wholeData =[];
if ($action == 'member_welcome_mail') {
$dataToInsert = $params['dataToInsert'];
$notification = $params['notification'];
@@ -37,7 +37,6 @@ class sendMailNotification
}
return $wholeData;
} else if($action == 'member_reminder_mail'){
-
$EmployeeModel = new EmployeeModel();
$emp_data = $params['emp_data'];
$notification_data = $params['notification_data'];
@@ -51,27 +50,46 @@ class sendMailNotification
$mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
$mail_content = str_replace("[[nhance_logo]]", "", $mail_content);
$mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
-
if ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) {
+ if(isset($emp_data['relationship'])){
+ if ($emp_data['relationship'] == 'Self') {
+ if(count($emp_data) > 0){
+ $mail ='';
+ if ($emp_data['relationship'] == 'Self') {
+ $employee_name =$emp_data['name'];
+ $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
+ $mail = $emp_data['email_corporate'];
+ }
+ }
+ }else{
+ $mail ='';
+ }
+
+ }else{
+ $employee_name =$emp_data['name'];
+ $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
+ $mail = $emp_data['email_corporate'];
+ }
+
+ if (isset($mail) && !empty($mail)) {
+ $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
+ }
+ }else{
foreach ($emp_data as $key => $value) {
- if ($value['relationship'] != 'Self') {
-
+ if ($value['relationship'] != 'Self') {
$emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll();
-
if(count($emp_data) > 1){
$mail ='';
foreach ($emp_data as $key => $values) {
if ($value['relationship'] == 'Self') {
$employee_name =$values['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
-
$mail = $values['email_corporate'];
}
}
}else{
$mail ='';
}
-
}else{
$employee_name =$value['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
@@ -81,13 +99,15 @@ class sendMailNotification
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
}
}
- if (count($wholeData) < 1) {
- $wholeData = [];
- }
- return $wholeData;
- }else{
- return "false";
}
+
+ if (count($wholeData) < 1) {
+ $wholeData = [];
+ }
+ return $wholeData;
+ // }else{
+ // return "false";
+ // }
} else if($action == 'member_ecard_mail'){
$notification = $params['notification'];
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index 05d09c98..9a4f3c0c 100644
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -19,6 +19,7 @@ class ClientPolicyModel extends Model
"policy_type_id",
"policy_start_date",
"policy_end_date",
+ "reminder_date",
"insured",
"no_of_employees",
"no_of_lives",
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index b0862573..527d4450 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -112,6 +112,10 @@
+