CHANGE_ENROLLMENT_STATUS_COORECT THE CODE : AADHAVAN

This commit is contained in:
aadhavan valli 2024-07-30 12:19:00 +05:30
parent a8f0a34762
commit 04e3e0f23a

View File

@ -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'){