From 04e3e0f23afbea4e320bc1ed5c0f3e23ef802714 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Tue, 30 Jul 2024 12:19:00 +0530 Subject: [PATCH] CHANGE_ENROLLMENT_STATUS_COORECT THE CODE : AADHAVAN --- app/Controllers/DashboardController.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 220c7468..79a90517 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -194,20 +194,19 @@ class DashboardController extends AdminController $employeePolicyModel = new EmployeePolicyModel(); $myLogger = \Config\Services::mylogger(); - $client_policy_data = $clientPolicyModel - ->where('id', 21) - ->findAll(); - $currentDate = date('Y-m-d'); + $client_policy_data = $clientPolicyModel->findAll(); + $currentDate = date('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['open_date']) { + $openDate = date('d', strtotime($client_policy['open_date'])); + $closeDate = date('d', strtotime($client_policy['close_date'])); + if ($currentDate == $openDate) { $clientPolicyModel->update($id, ['open_for_enrollment' => 1]); } - if ($client_policy['close_date'] < $currentDate) { + if ($closeDate < $currentDate) { $clientPolicyModel->update($id, ['open_for_enrollment' => 0]); } } @@ -224,13 +223,15 @@ class DashboardController extends AdminController ->first(); // Check if notification should be sent - if ($notification_data && $notification_data['enabled'] == 1 && $currentDate == $client_policy['reminder_date']) { + if ($notification_data && $notification_data['enabled'] == 1 && $currentDate == date('d', strtotime($client_policy['reminder_date'])) ) { // Fetch all employees related to the client policy $employees = $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('employee_polices.status', 'draft') + ->where('employees.relationship', 'Self') ->findAll(); - // Process each employee foreach ($employees as $employee) { if($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self'){