FIX_HRACCESS_CTRL_ISSUE
This commit is contained in:
parent
bb78dada40
commit
927995b847
@ -6240,45 +6240,74 @@ class ClientController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
foreach ($hrAccessTableData as $access) {
|
// First create a map of HR data by post_hr_id for quick lookup
|
||||||
foreach ($merged as $hr) {
|
$hrMap = [];
|
||||||
if ($hr['post_hr_id'] == $access['post_hr_id']) {
|
foreach ($merged as $hr) {
|
||||||
|
$hrMap[$hr['post_hr_id']] = $hr;
|
||||||
$allowed_modules = json_decode($access['allowed_modules'], true) ?? null;
|
}
|
||||||
if ($allowed_modules == null) {
|
|
||||||
$allowed_pre_modules = null;
|
// Process access data first
|
||||||
$allowed_post_modules = null;
|
foreach ($hrAccessTableData as $access) {
|
||||||
} else {
|
$post_hr_id = $access['post_hr_id'];
|
||||||
|
|
||||||
|
// Check if this HR exists in our merged data
|
||||||
|
if (isset($hrMap[$post_hr_id])) {
|
||||||
|
$hr = $hrMap[$post_hr_id];
|
||||||
|
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
|
||||||
|
|
||||||
|
// Parse allowed modules
|
||||||
|
$allowed_modules = json_decode($access['allowed_modules'], true) ?? null;
|
||||||
$allowed_pre_modules = $allowed_modules['pre'] ?? [];
|
$allowed_pre_modules = $allowed_modules['pre'] ?? [];
|
||||||
$allowed_post_modules = $allowed_modules['post'] ?? [];
|
$allowed_post_modules = $allowed_modules['post'] ?? [];
|
||||||
|
|
||||||
|
$result[$temp_arr_key] = [
|
||||||
|
'hr_access_table_pk' => $access['id'] ?? null,
|
||||||
|
'post_client_id' => $access['post_client_id'] ?? null,
|
||||||
|
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
|
||||||
|
'post_hr_id' => $hr['post_hr_id'] ?? null,
|
||||||
|
'allowed_pre_modules' => $allowed_pre_modules,
|
||||||
|
'allowed_post_modules' => $allowed_post_modules,
|
||||||
|
'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [],
|
||||||
|
'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [],
|
||||||
|
'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [],
|
||||||
|
'hr_name' => $hr['hr_name'],
|
||||||
|
'hr_mobile' => $hr['hr_mobile'],
|
||||||
|
'hr_mail' => $hr['hr_mail']
|
||||||
|
];
|
||||||
|
|
||||||
|
// Remove from map so we know it's been processed
|
||||||
|
unset($hrMap[$post_hr_id]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$result[] = [
|
|
||||||
'hr_access_table_pk' => $access['id'] ?? null,
|
// Now process any remaining HRs that didn't have access records
|
||||||
'post_client_id' => $access['post_client_id'] ?? null,
|
foreach ($hrMap as $hr) {
|
||||||
|
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
|
||||||
|
|
||||||
|
$result[$temp_arr_key] = [
|
||||||
|
'hr_access_table_pk' => null,
|
||||||
|
'post_client_id' => $client_id ?? null,
|
||||||
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
|
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
|
||||||
'post_hr_id' => $hr['post_hr_id'] ?? null,
|
'post_hr_id' => $hr['post_hr_id'] ?? null,
|
||||||
'allowed_pre_modules' => $allowed_pre_modules,
|
'allowed_pre_modules' => [],
|
||||||
'allowed_post_modules' => $allowed_post_modules,
|
'allowed_post_modules' => [],
|
||||||
'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [],
|
'allowed_pre_policies' => [],
|
||||||
'allowed_active_policies' => json_decode($access['allowed_active_policies']) ?? [],
|
'allowed_active_policies' => [],
|
||||||
'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [],
|
'allowed_cd' => [],
|
||||||
'hr_name' => $hr['hr_name'],
|
'hr_name' => $hr['hr_name'] ?? null,
|
||||||
'hr_mobile' => $hr['hr_mobile'],
|
'hr_mobile' => $hr['hr_mobile'] ?? null,
|
||||||
'hr_mail' => $hr['hr_mail']
|
'hr_mail' => $hr['hr_mail'] ?? null,
|
||||||
];
|
];
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$resultData['hr_access_data'] = $result;
|
$resultData['hr_access_data'] = array_values($result);
|
||||||
$resultData['pre_policy_data'] = $data['pre_policy_data'];
|
$resultData['pre_policy_data'] = $data['pre_policy_data'];
|
||||||
$resultData['post_policy_data'] = $data['post_policy_data'];
|
$resultData['post_policy_data'] = $data['post_policy_data'];
|
||||||
$resultData['post_cd_data'] = $data['post_cd_data'];
|
$resultData['post_cd_data'] = $data['post_cd_data'];
|
||||||
|
// echo '**********************************************';
|
||||||
// dd($resultData);
|
// print_rr($resultData);die();
|
||||||
|
|
||||||
return $resultData;
|
return $resultData;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user