CHANGE_VIEW_ENROLLMENT_FAMILY_FILTER_AND_POLICY_TERMS_SCRIPT : RV

This commit is contained in:
VENKATESHWARAN 2024-11-28 15:31:48 +05:30
parent 97a6cd6512
commit 038475ae0f
3 changed files with 54 additions and 63 deletions

View File

@ -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]);
}
}
}

View File

@ -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,

View File

@ -180,6 +180,7 @@
<th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">Name</th>
<th class="font-weight-medium">Emp Code</th>
<th class="font-weight-medium">Relationship</th>
<th class="font-weight-medium">Enroled</th>
<th class="font-weight-medium">Logged-In</th>
</tr>
@ -336,6 +337,7 @@
index + 1,
employee.employee_name,
employee.emp_code,
employee.relationship,
enrolled,
loggedIn
]);