FIX_HR_RELATED_ISSUES
This commit is contained in:
parent
8e67f68dce
commit
bdb678e59a
@ -5661,7 +5661,7 @@ class ClientController extends AdminController
|
||||
|
||||
// $employeeController = new EmployeeController();
|
||||
// $employeeController->truncateFileData('633');
|
||||
// $res = $this->getHrAccessData(4005); dd($res);
|
||||
// $res = $this->getHrAccessData(4075); dd($res);
|
||||
|
||||
// ---------- TICKET SERVICE CONTROLLER --------------------------------------------------------------------------------
|
||||
|
||||
@ -7025,177 +7025,434 @@ class ClientController extends AdminController
|
||||
return $combinedHrAccessData;
|
||||
}
|
||||
|
||||
// do not remove this commented items
|
||||
// public function constructHrAccessData($data, $client_id , $pre_client_id)
|
||||
// {
|
||||
// // print_rr($data);die;
|
||||
|
||||
// $preHrs = $data['pre_hr_data'];
|
||||
// $postHrs = $data['post_hr_data'];
|
||||
// $hrAccessTableData = $data['hr_access_table_data'];
|
||||
// $merged = [];
|
||||
|
||||
// // Merge based on mobile and email
|
||||
// foreach ($postHrs as $post) {
|
||||
// $found = false;
|
||||
// foreach ($preHrs as $index => $pre) {
|
||||
|
||||
// if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) {
|
||||
|
||||
// $merged[] = [
|
||||
// 'pre_hr_id' => $pre['pre_hr_id'],
|
||||
// 'post_hr_id' => $post['post_hr_id'],
|
||||
// 'hr_name' => $post['hr_name'],
|
||||
// 'hr_mobile' => $post['hr_mobile'],
|
||||
// 'hr_mail' => $post['hr_mail'],
|
||||
// 'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
// 'post_branch_id' => $post['post_branch_id'] ?? null,
|
||||
// 'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
// ];
|
||||
// unset($preHrs[$index]); // remove matched pre_hr
|
||||
// $found = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!$found) {
|
||||
// $merged[] = [
|
||||
// 'pre_hr_id' => null,
|
||||
// 'post_hr_id' => $post['post_hr_id'],
|
||||
// 'hr_name' => $post['hr_name'],
|
||||
// 'hr_mobile' => $post['hr_mobile'],
|
||||
// 'hr_mail' => $post['hr_mail'],
|
||||
// 'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
// 'post_branch_id' => $post['post_branch_id'] ?? null ,
|
||||
// 'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Remaining preHrs (not matched)
|
||||
// foreach ($preHrs as $pre) {
|
||||
|
||||
// foreach ($merged as $value) {
|
||||
// if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) {
|
||||
// continue 2; // Skip adding this pre_hr as it's already matched
|
||||
// }
|
||||
// }
|
||||
|
||||
// $merged[] = [
|
||||
// 'pre_hr_id' => $pre['pre_hr_id'],
|
||||
// 'post_hr_id' => null,
|
||||
// 'hr_name' => $pre['hr_name'],
|
||||
// 'hr_mobile' => $pre['hr_mobile'],
|
||||
// 'hr_mail' => $pre['hr_mail'],
|
||||
// 'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
// 'post_branch_id' => $post['post_branch_id'] ?? null ,
|
||||
// 'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
// ];
|
||||
// }
|
||||
|
||||
// // dd($merged);
|
||||
|
||||
// $result = [];
|
||||
|
||||
// if (empty($hrAccessTableData)) {
|
||||
|
||||
// // No access data — fill result with hr data and other fields as null
|
||||
// foreach ($merged as $hr) {
|
||||
// $result[] = [
|
||||
// 'hr_access_table_pk' => null,
|
||||
// 'post_client_id' => $client_id ?? null,
|
||||
// 'pre_hr_id' => $hr['pre_hr_id'] ?? null,
|
||||
// 'post_hr_id' => $hr['post_hr_id'] ?? null,
|
||||
// 'allowed_pre_modules' => [],
|
||||
// 'allowed_post_modules' => [],
|
||||
// 'allowed_pre_policies' => [],
|
||||
// 'allowed_active_policies' => [],
|
||||
// 'allowed_cd' => [],
|
||||
// 'hr_name' => $hr['hr_name'] ?? null,
|
||||
// 'hr_mobile' => $hr['hr_mobile'] ?? null,
|
||||
// 'hr_mail' => $hr['hr_mail'] ?? null,
|
||||
// 'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
// 'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
// 'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
// 'pre_client_id' => $pre_client_id ?? null
|
||||
// ];
|
||||
// }
|
||||
// } else {
|
||||
// // First create a map of HR data by post_hr_id for quick lookup
|
||||
// $hrMap = [];
|
||||
// foreach ($merged as $hr) {
|
||||
// $hrMap[$hr['post_hr_id']] = $hr;
|
||||
// }
|
||||
|
||||
// // Process access data first
|
||||
// foreach ($hrAccessTableData as $access) {
|
||||
// $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_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'],
|
||||
// 'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
// 'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
// 'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
// 'pre_client_id' => $pre_client_id ?? null
|
||||
// ];
|
||||
|
||||
// // Remove from map so we know it's been processed
|
||||
// unset($hrMap[$post_hr_id]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Now process any remaining HRs that didn't have access records
|
||||
// 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,
|
||||
// 'post_hr_id' => $hr['post_hr_id'] ?? null,
|
||||
// 'allowed_pre_modules' => [],
|
||||
// 'allowed_post_modules' => [],
|
||||
// 'allowed_pre_policies' => [],
|
||||
// 'allowed_active_policies' => [],
|
||||
// 'allowed_cd' => [],
|
||||
// 'hr_name' => $hr['hr_name'] ?? null,
|
||||
// 'hr_mobile' => $hr['hr_mobile'] ?? null,
|
||||
// 'hr_mail' => $hr['hr_mail'] ?? null,
|
||||
// 'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
// 'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
// 'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
// 'pre_client_id' => $pre_client_id ?? null
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// $resultData['hr_access_data'] = array_values($result);
|
||||
// $resultData['pre_policy_data'] = $data['pre_policy_data'];
|
||||
// $resultData['post_policy_data'] = $data['post_policy_data'];
|
||||
// $resultData['post_cd_data'] = $data['post_cd_data'];
|
||||
|
||||
// return $resultData;
|
||||
// }
|
||||
|
||||
public function constructHrAccessData($data, $client_id , $pre_client_id)
|
||||
{
|
||||
// print_rr($data);die;
|
||||
{
|
||||
try{
|
||||
|
||||
$preHrs = $data['pre_hr_data'];
|
||||
$postHrs = $data['post_hr_data'];
|
||||
$hrAccessTableData = $data['hr_access_table_data'];
|
||||
$merged = [];
|
||||
$preHrs = $data['pre_hr_data'];
|
||||
$postHrs = $data['post_hr_data'];
|
||||
$hrAccessTableData = $data['hr_access_table_data'];
|
||||
$merged = [];
|
||||
|
||||
// Merge based on mobile and email
|
||||
foreach ($postHrs as $post) {
|
||||
$found = false;
|
||||
foreach ($preHrs as $index => $pre) {
|
||||
// Merge based on mobile and email
|
||||
foreach ($postHrs as $post) {
|
||||
$found = false;
|
||||
foreach ($preHrs as $index => $pre) {
|
||||
|
||||
if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) {
|
||||
if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) {
|
||||
|
||||
$merged[] = [
|
||||
'pre_hr_id' => $pre['pre_hr_id'],
|
||||
'post_hr_id' => $post['post_hr_id'],
|
||||
'hr_name' => $post['hr_name'],
|
||||
'hr_mobile' => $post['hr_mobile'],
|
||||
'hr_mail' => $post['hr_mail'],
|
||||
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $post['post_branch_id'] ?? null,
|
||||
'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
];
|
||||
unset($preHrs[$index]); // remove matched pre_hr
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$merged[] = [
|
||||
'pre_hr_id' => $pre['pre_hr_id'],
|
||||
'pre_hr_id' => null,
|
||||
'post_hr_id' => $post['post_hr_id'],
|
||||
'hr_name' => $post['hr_name'],
|
||||
'hr_mobile' => $post['hr_mobile'],
|
||||
'hr_mail' => $post['hr_mail'],
|
||||
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $post['post_branch_id'] ?? null,
|
||||
'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
'post_branch_id' => $post['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
];
|
||||
unset($preHrs[$index]); // remove matched pre_hr
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
// Remaining preHrs (not matched)
|
||||
foreach ($preHrs as $pre) {
|
||||
|
||||
foreach ($merged as $value) {
|
||||
if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) {
|
||||
continue 2; // Skip adding this pre_hr as it's already matched
|
||||
}
|
||||
}
|
||||
|
||||
$merged[] = [
|
||||
'pre_hr_id' => null,
|
||||
'post_hr_id' => $post['post_hr_id'],
|
||||
'hr_name' => $post['hr_name'],
|
||||
'hr_mobile' => $post['hr_mobile'],
|
||||
'hr_mail' => $post['hr_mail'],
|
||||
'pre_hr_id' => $pre['pre_hr_id'],
|
||||
'post_hr_id' => null,
|
||||
'hr_name' => $pre['hr_name'],
|
||||
'hr_mobile' => $pre['hr_mobile'],
|
||||
'hr_mail' => $pre['hr_mail'],
|
||||
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $post['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Remaining preHrs (not matched)
|
||||
foreach ($preHrs as $pre) {
|
||||
$result = [];
|
||||
|
||||
foreach ($merged as $value) {
|
||||
if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) {
|
||||
continue 2; // Skip adding this pre_hr as it's already matched
|
||||
}
|
||||
}
|
||||
|
||||
$merged[] = [
|
||||
'pre_hr_id' => $pre['pre_hr_id'],
|
||||
'post_hr_id' => null,
|
||||
'hr_name' => $pre['hr_name'],
|
||||
'hr_mobile' => $pre['hr_mobile'],
|
||||
'hr_mail' => $pre['hr_mail'],
|
||||
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $post['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
];
|
||||
}
|
||||
if (empty($hrAccessTableData)) {
|
||||
|
||||
// dd($merged);
|
||||
|
||||
$result = [];
|
||||
|
||||
if (empty($hrAccessTableData)) {
|
||||
|
||||
// No access data — fill result with hr data and other fields as null
|
||||
foreach ($merged as $hr) {
|
||||
$result[] = [
|
||||
'hr_access_table_pk' => null,
|
||||
'post_client_id' => $client_id ?? null,
|
||||
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
|
||||
'post_hr_id' => $hr['post_hr_id'] ?? null,
|
||||
'allowed_pre_modules' => [],
|
||||
'allowed_post_modules' => [],
|
||||
'allowed_pre_policies' => [],
|
||||
'allowed_active_policies' => [],
|
||||
'allowed_cd' => [],
|
||||
'hr_name' => $hr['hr_name'] ?? null,
|
||||
'hr_mobile' => $hr['hr_mobile'] ?? null,
|
||||
'hr_mail' => $hr['hr_mail'] ?? null,
|
||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
'pre_client_id' => $pre_client_id ?? null
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// First create a map of HR data by post_hr_id for quick lookup
|
||||
$hrMap = [];
|
||||
foreach ($merged as $hr) {
|
||||
$hrMap[$hr['post_hr_id']] = $hr;
|
||||
}
|
||||
|
||||
// Process access data first
|
||||
foreach ($hrAccessTableData as $access) {
|
||||
$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_post_modules = $allowed_modules['post'] ?? [];
|
||||
|
||||
$result[$temp_arr_key] = [
|
||||
'hr_access_table_pk' => $access['id'] ?? null,
|
||||
'post_client_id' => $access['post_client_id'] ?? null,
|
||||
// No access data — fill result with hr data and other fields as null
|
||||
foreach ($merged as $hr) {
|
||||
$result[] = [
|
||||
'hr_access_table_pk' => null,
|
||||
'post_client_id' => $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'],
|
||||
'allowed_pre_modules' => [],
|
||||
'allowed_post_modules' => [],
|
||||
'allowed_pre_policies' => [],
|
||||
'allowed_active_policies' => [],
|
||||
'allowed_cd' => [],
|
||||
'hr_name' => $hr['hr_name'] ?? null,
|
||||
'hr_mobile' => $hr['hr_mobile'] ?? null,
|
||||
'hr_mail' => $hr['hr_mail'] ?? null,
|
||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
'pre_client_id' => $pre_client_id ?? null
|
||||
];
|
||||
}
|
||||
|
||||
// Remove from map so we know it's been processed
|
||||
unset($hrMap[$post_hr_id]);
|
||||
} else {
|
||||
|
||||
// First create a map of HR data by post_hr_id for quick lookup
|
||||
$hrMap = [];
|
||||
foreach ($merged as $hr) {
|
||||
if(!empty($hr['post_hr_id'])){
|
||||
$hrMap['post_hr_id_' . $hr['post_hr_id']] = $hr;
|
||||
}else{
|
||||
$hrMap['pre_hr_id_' . $hr['pre_hr_id']] = $hr;
|
||||
}
|
||||
}
|
||||
|
||||
// Process access data first
|
||||
foreach ($hrAccessTableData as $access) {
|
||||
|
||||
$post_hr_id = $access['post_hr_id'];
|
||||
$pre_hr_id = $access['pre_hr_id'];
|
||||
|
||||
if (empty($post_hr_id) && !empty($pre_hr_id)) {
|
||||
$type_of_access_data = "PRE";
|
||||
} elseif (!empty($post_hr_id) && empty($pre_hr_id)) {
|
||||
$type_of_access_data = "POST";
|
||||
} elseif (!empty($post_hr_id) && !empty($pre_hr_id)) {
|
||||
$type_of_access_data = "POST&PRE";
|
||||
} else {
|
||||
$type_of_access_data = "UNKNOWN";
|
||||
}
|
||||
|
||||
// Check if this HR exists in our merged data
|
||||
if (isset($hrMap['post_hr_id_' . $post_hr_id])) {
|
||||
|
||||
$hr = $hrMap['post_hr_id_' . $post_hr_id];
|
||||
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'] . $post_hr_id;
|
||||
|
||||
// Parse allowed modules
|
||||
$allowed_modules = json_decode($access['allowed_modules'], true) ?? null;
|
||||
$allowed_pre_modules = $allowed_modules['pre'] ?? [];
|
||||
$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'],
|
||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
'pre_client_id' => $pre_client_id ?? null,
|
||||
'type_of_access_data' => $type_of_access_data ?? null
|
||||
];
|
||||
|
||||
// Remove from map so we know it's been processed
|
||||
unset($hrMap['post_hr_id_' . $post_hr_id]);
|
||||
|
||||
}else if (isset($hrMap['pre_hr_id_' . $pre_hr_id])){
|
||||
|
||||
$hr = $hrMap['pre_hr_id_' . $pre_hr_id];
|
||||
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'] . $post_hr_id;
|
||||
|
||||
// Parse allowed modules
|
||||
$allowed_modules = json_decode($access['allowed_modules'], true) ?? null;
|
||||
$allowed_pre_modules = $allowed_modules['pre'] ?? [];
|
||||
$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'],
|
||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
'pre_client_id' => $pre_client_id ?? null,
|
||||
'type_of_access_data' => $type_of_access_data ?? null
|
||||
];
|
||||
|
||||
// Remove from map so we know it's been processed
|
||||
unset($hrMap['pre_hr_id_' . $pre_hr_id]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Now process any remaining HRs that didn't have access records
|
||||
foreach ($hrMap as $hr) {
|
||||
|
||||
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
|
||||
$post_hr_id = $hr['post_hr_id'];
|
||||
$pre_hr_id = $hr['pre_hr_id'];
|
||||
|
||||
if (empty($post_hr_id) && !empty($pre_hr_id)) {
|
||||
$type_of_access_data = "PRE";
|
||||
} elseif (!empty($post_hr_id) && empty($pre_hr_id)) {
|
||||
$type_of_access_data = "POST";
|
||||
} elseif (!empty($post_hr_id) && !empty($pre_hr_id)) {
|
||||
$type_of_access_data = "POST&PRE";
|
||||
} else {
|
||||
$type_of_access_data = "UNKNOWN";
|
||||
}
|
||||
|
||||
$result[$temp_arr_key] = [
|
||||
'hr_access_table_pk' => null,
|
||||
'post_client_id' => $client_id ?? null,
|
||||
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
|
||||
'post_hr_id' => $hr['post_hr_id'] ?? null,
|
||||
'allowed_pre_modules' => [],
|
||||
'allowed_post_modules' => [],
|
||||
'allowed_pre_policies' => [],
|
||||
'allowed_active_policies' => [],
|
||||
'allowed_cd' => [],
|
||||
'hr_name' => $hr['hr_name'] ?? null,
|
||||
'hr_mobile' => $hr['hr_mobile'] ?? null,
|
||||
'hr_mail' => $hr['hr_mail'] ?? null,
|
||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
'pre_client_id' => $pre_client_id ?? null,
|
||||
'type_of_access_data' => $type_of_access_data ?? null
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Now process any remaining HRs that didn't have access records
|
||||
foreach ($hrMap as $hr) {
|
||||
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
|
||||
// dd($result);
|
||||
$resultData['hr_access_data'] = array_values($result);
|
||||
$resultData['pre_policy_data'] = $data['pre_policy_data'];
|
||||
$resultData['post_policy_data'] = $data['post_policy_data'];
|
||||
$resultData['post_cd_data'] = $data['post_cd_data'];
|
||||
|
||||
$result[$temp_arr_key] = [
|
||||
'hr_access_table_pk' => null,
|
||||
'post_client_id' => $client_id ?? null,
|
||||
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
|
||||
'post_hr_id' => $hr['post_hr_id'] ?? null,
|
||||
'allowed_pre_modules' => [],
|
||||
'allowed_post_modules' => [],
|
||||
'allowed_pre_policies' => [],
|
||||
'allowed_active_policies' => [],
|
||||
'allowed_cd' => [],
|
||||
'hr_name' => $hr['hr_name'] ?? null,
|
||||
'hr_mobile' => $hr['hr_mobile'] ?? null,
|
||||
'hr_mail' => $hr['hr_mail'] ?? null,
|
||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
'pre_client_id' => $pre_client_id ?? null
|
||||
];
|
||||
}
|
||||
return $resultData;
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateInsurerStatement: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString());
|
||||
return [];
|
||||
$errorData = [
|
||||
'message' => $th->getMessage(),
|
||||
'file' => $th->getFile(),
|
||||
'line' => $th->getLine(),
|
||||
'code' => $th->getCode(),
|
||||
'trace' => $th->getTraceAsString(),
|
||||
'trace_array' => $th->getTrace(), // full array version (optional)
|
||||
'function' => $th->getTrace()[0]['function'] ?? null,
|
||||
'class' => $th->getTrace()[0]['class'] ?? null,
|
||||
];
|
||||
return ['status' => 'failed', 'code' => 500, 'message' => $th->getMessage(), 'error_data' => $errorData];
|
||||
}
|
||||
|
||||
|
||||
$resultData['hr_access_data'] = array_values($result);
|
||||
$resultData['pre_policy_data'] = $data['pre_policy_data'];
|
||||
$resultData['post_policy_data'] = $data['post_policy_data'];
|
||||
$resultData['post_cd_data'] = $data['post_cd_data'];
|
||||
|
||||
return $resultData;
|
||||
}
|
||||
|
||||
public function saveHrAccessData()
|
||||
@ -7846,7 +8103,4 @@ class ClientController extends AdminController
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -60,7 +60,6 @@
|
||||
<?php } ?>
|
||||
</style>
|
||||
|
||||
|
||||
<div class="container-fluid-min">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@ -135,14 +134,18 @@
|
||||
<?php foreach ($pre_policy_data as $key1 => $policies) {
|
||||
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
||||
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
||||
if (
|
||||
in_array($policies['branch_id'].'-'.$policies['policy_no'], $listed_pre)
|
||||
&&
|
||||
$value['pre_branch_id'] != $policies['branch_id']
|
||||
) {
|
||||
// if (
|
||||
// in_array($policies['branch_id'].'-'.$policies['policy_no'], $listed_pre)
|
||||
// &&
|
||||
// $value['pre_branch_id'] != $policies['branch_id']
|
||||
// ) {
|
||||
// continue;
|
||||
// } else {
|
||||
// $listed_pre[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
||||
// }
|
||||
|
||||
if($value['pre_branch_id'] !== $policies['branch_id']){
|
||||
continue;
|
||||
} else {
|
||||
$listed_pre[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
||||
}
|
||||
?>
|
||||
<div class="checkbox-item">
|
||||
@ -196,17 +199,21 @@
|
||||
<?php foreach ($post_policy_data as $key2 => $policies) {
|
||||
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
||||
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
||||
if(
|
||||
in_array($policies['branch_id'].'-'.$policies['policy_no'] , $listed_post)
|
||||
&&
|
||||
$value['post_branch_id'] != $policies['branch_id']
|
||||
)
|
||||
{
|
||||
// if(
|
||||
// in_array($policies['branch_id'].'-'.$policies['policy_no'] , $listed_post)
|
||||
// &&
|
||||
// $value['post_branch_id'] != $policies['branch_id']
|
||||
// )
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $listed_post[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
||||
// }
|
||||
|
||||
if($value['post_branch_id'] !== $policies['branch_id']){
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$listed_post[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user