diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 06f29c30..7b8e9cf8 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -3583,10 +3583,10 @@ class ClientController extends AdminController { $data = $this->clientPolicyModel - ->where("policy_terms IS NOT NULL AND policy_terms <> ''") - ->where('policy_type_id', 2) - ->where('is_active', 1) - ->findAll(); + ->where("policy_terms IS NOT NULL AND policy_terms <> ''") + ->where('policy_type_id', 2) + ->where('is_active', 1) + ->findAll(); for ($i = 0; $i < count($data); $i++) { @@ -3599,80 +3599,63 @@ class ClientController extends AdminController // Set default value of copayzonewisecopay to "empty" $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty'; - // Initialize an empty array for the ordered policy terms $orderedPolicyTerms = []; // Add copayzonewisecopay and copayzonewisecopaydata if they exist_ if (isset($policyTerms['copayzonewisecopay'])) { - - $orderedPolicyTerms['copayzonewisecopay'] = $policyTerms['copayzonewisecopay']; - $orderedPolicyTerms['co_pay_details'] = isset($policyTerms['co_pay_details']) ? $policyTerms['co_pay_details'] : ''; - } + if(!isset($policyTerms['co_pay_details'])){ + + $co_pay_details_value = ""; + if (strtolower($ans) == "nil" || $ans == 0) { + $policyTerms['copayzonewisecopay'] = 0; + $co_pay_details_value = ""; + } elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) { + $policyTerms['copayzonewisecopay'] = 1; + $co_pay_details_value = $ans; + } + + $co_pay_index = array_search('copayzonewisecopay', array_keys($policyTerms)); + $orderedPolicyTerms[] = [ + "key" => "co_pay_details", + "value" => $co_pay_details_value, + "position" => $co_pay_index + 1, + ]; + + unset($policyTerms['optionalparentalcopay']); + + } + } // Add ailmentcapping and ailmentcappingdata if they exist_ if (isset($policyTerms['ailmentcapping'])) { - $orderedPolicyTerms['ailmentcapping'] = $policyTerms['ailmentcapping']; - $orderedPolicyTerms['ailment_capping_details'] = isset($policyTerms['ailment_capping_details']) ? $policyTerms['ailment_capping_details'] : ''; - } - - - // Now add the rest of the policy terms that are not copayzonewisecopay, copayzonewisecopaydata, ailmentcapping, or ailmentcapping_data_ - foreach ($policyTerms as $key => $value) { - if (!in_array($key, ['copayzonewisecopay', 'co_pay_details', 'ailmentcapping', 'ailment_capping_details'])) { - $orderedPolicyTerms[$key] = $value; + if(!isset($policyTerms['ailment_capping_details'])){ + $aliment_index = array_search('ailmentcapping', array_keys($policyTerms)); + $orderedPolicyTerms[] = [ + "key" => "ailment_capping_details", + "value" => "", + "position" => $aliment_index + 2, + ]; } } + foreach ($orderedPolicyTerms as $term) { + $position = $term['position']; + $key = $term['key']; + $value = $term['value']; // Insert the key-value pair at the specified index + $policyTerms = array_merge( + array_slice($policyTerms, 0, $position, true), + [$key => $value], + array_slice($policyTerms, $position, null, true) + ); + } // Re-encode the ordered policy terms - $updatedPolicyTerms = json_encode($orderedPolicyTerms); + $updatedPolicyTerms = json_encode($policyTerms); - - // Update the policyterms in the database_ + // dd($orderedPolicyTerms, $updatedPolicyTerms); $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]); - - - // Handle different conditions for copayzonewisecopay - if (strtolower($ans) == "nil" || $ans == 0) { - // If copayzonewisecopay is "nil" or 0, reset it to 0 and add copayzonewisecopaydata as empty_ - if (isset($orderedPolicyTerms['copayzonewisecopay'])) { - $orderedPolicyTerms['copayzonewisecopay'] = 0; - $orderedPolicyTerms['co_pay_details'] = ""; - } - - - // Rebuild the array after modification - foreach ($policyTerms as $key => $value) { - if (!in_array($key, ['copayzonewisecopay', 'co_pay_details'])) { - $orderedPolicyTerms[$key] = $value; - } - } - - - $updatedPolicyTerms = json_encode($orderedPolicyTerms); - $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]); - continue; - } elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) { - // If copayzonewisecopay has a valid value, update it - if (isset($orderedPolicyTerms['copayzonewisecopay'])) { - $orderedPolicyTerms['copayzonewisecopay'] = 1; - $orderedPolicyTerms['co_pay_details'] = $ans; - } - - - // Rebuild the array after modification - foreach ($policyTerms as $key => $value) { - if (!in_array($key, ['copayzonewisecopay', 'co_pay_details'])) { - $orderedPolicyTerms[$key] = $value; - } - } - - - $updatedPolicyTerms = json_encode($orderedPolicyTerms); - $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]); - } } } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index c308d65f..9afb44b2 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -734,11 +734,16 @@ class EmployeeController extends AdminController employees.emp_status, auth_history.user_type') ->join('employees', $client_id .'= employees.client_id AND ' . $branch_id . '= employees.client_branch_id', 'left') ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left') + ->where('employees.is_active', 1) + ->where('employees.emp_status !=', 'truncated') + ->groupBy('employees.id') ->findAll(); $groupedData = []; $employeeId = ''; + foreach ($results as $row) { + if($employeeId != $row['employee_id']){ $employeeId = $row['employee_id']; }else{ @@ -751,7 +756,8 @@ class EmployeeController extends AdminController $employeeUserType = $row['user_type']; - if ($employeeId !== null && $employeeRelationship == 'Self') { + // if ($employeeId !== null && $employeeRelationship == 'Self') { + if ($employeeId !== null) { // Append employee info to the branch's employees list $groupedData[] = [ 'employee_id' => $employeeId, diff --git a/app/Views/enrollment_list.php b/app/Views/enrollment_list.php index 3d37096a..edbdd473 100755 --- a/app/Views/enrollment_list.php +++ b/app/Views/enrollment_list.php @@ -180,6 +180,7 @@ SNO Name Emp Code + Relationship Enroled Logged-In @@ -336,6 +337,7 @@ index + 1, employee.employee_name, employee.emp_code, + employee.relationship, enrolled, loggedIn ]);