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 = new EmployeeController();
|
||||||
// $employeeController->truncateFileData('633');
|
// $employeeController->truncateFileData('633');
|
||||||
// $res = $this->getHrAccessData(4005); dd($res);
|
// $res = $this->getHrAccessData(4075); dd($res);
|
||||||
|
|
||||||
// ---------- TICKET SERVICE CONTROLLER --------------------------------------------------------------------------------
|
// ---------- TICKET SERVICE CONTROLLER --------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -7025,177 +7025,434 @@ class ClientController extends AdminController
|
|||||||
return $combinedHrAccessData;
|
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)
|
public function constructHrAccessData($data, $client_id , $pre_client_id)
|
||||||
{
|
{
|
||||||
// print_rr($data);die;
|
try{
|
||||||
|
|
||||||
$preHrs = $data['pre_hr_data'];
|
$preHrs = $data['pre_hr_data'];
|
||||||
$postHrs = $data['post_hr_data'];
|
$postHrs = $data['post_hr_data'];
|
||||||
$hrAccessTableData = $data['hr_access_table_data'];
|
$hrAccessTableData = $data['hr_access_table_data'];
|
||||||
$merged = [];
|
$merged = [];
|
||||||
|
|
||||||
// Merge based on mobile and email
|
// Merge based on mobile and email
|
||||||
foreach ($postHrs as $post) {
|
foreach ($postHrs as $post) {
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach ($preHrs as $index => $pre) {
|
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[] = [
|
$merged[] = [
|
||||||
'pre_hr_id' => $pre['pre_hr_id'],
|
'pre_hr_id' => null,
|
||||||
'post_hr_id' => $post['post_hr_id'],
|
'post_hr_id' => $post['post_hr_id'],
|
||||||
'hr_name' => $post['hr_name'],
|
'hr_name' => $post['hr_name'],
|
||||||
'hr_mobile' => $post['hr_mobile'],
|
'hr_mobile' => $post['hr_mobile'],
|
||||||
'hr_mail' => $post['hr_mail'],
|
'hr_mail' => $post['hr_mail'],
|
||||||
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||||
'post_branch_id' => $post['post_branch_id'] ?? null,
|
'post_branch_id' => $post['post_branch_id'] ?? null ,
|
||||||
'post_branch_name' => $post['post_branch_name'] ?? 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[] = [
|
$merged[] = [
|
||||||
'pre_hr_id' => null,
|
'pre_hr_id' => $pre['pre_hr_id'],
|
||||||
'post_hr_id' => $post['post_hr_id'],
|
'post_hr_id' => null,
|
||||||
'hr_name' => $post['hr_name'],
|
'hr_name' => $pre['hr_name'],
|
||||||
'hr_mobile' => $post['hr_mobile'],
|
'hr_mobile' => $pre['hr_mobile'],
|
||||||
'hr_mail' => $post['hr_mail'],
|
'hr_mail' => $pre['hr_mail'],
|
||||||
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||||
'post_branch_id' => $post['post_branch_id'] ?? null ,
|
'post_branch_id' => $post['post_branch_id'] ?? null ,
|
||||||
'post_branch_name' => $post['post_branch_name'] ?? null
|
'post_branch_name' => $post['post_branch_name'] ?? null
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Remaining preHrs (not matched)
|
$result = [];
|
||||||
foreach ($preHrs as $pre) {
|
|
||||||
|
|
||||||
foreach ($merged as $value) {
|
if (empty($hrAccessTableData)) {
|
||||||
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[] = [
|
// No access data — fill result with hr data and other fields as null
|
||||||
'pre_hr_id' => $pre['pre_hr_id'],
|
foreach ($merged as $hr) {
|
||||||
'post_hr_id' => null,
|
$result[] = [
|
||||||
'hr_name' => $pre['hr_name'],
|
'hr_access_table_pk' => null,
|
||||||
'hr_mobile' => $pre['hr_mobile'],
|
'post_client_id' => $client_id ?? null,
|
||||||
'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,
|
'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'], true) ?? [],
|
'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,
|
||||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||||
'pre_client_id' => $pre_client_id ?? null
|
'pre_client_id' => $pre_client_id ?? null
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// Remove from map so we know it's been processed
|
} else {
|
||||||
unset($hrMap[$post_hr_id]);
|
|
||||||
|
// 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
|
// dd($result);
|
||||||
foreach ($hrMap as $hr) {
|
$resultData['hr_access_data'] = array_values($result);
|
||||||
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
|
$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] = [
|
return $resultData;
|
||||||
'hr_access_table_pk' => null,
|
|
||||||
'post_client_id' => $client_id ?? null,
|
} catch (\Throwable $th) {
|
||||||
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
|
|
||||||
'post_hr_id' => $hr['post_hr_id'] ?? null,
|
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateInsurerStatement: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString());
|
||||||
'allowed_pre_modules' => [],
|
return [];
|
||||||
'allowed_post_modules' => [],
|
$errorData = [
|
||||||
'allowed_pre_policies' => [],
|
'message' => $th->getMessage(),
|
||||||
'allowed_active_policies' => [],
|
'file' => $th->getFile(),
|
||||||
'allowed_cd' => [],
|
'line' => $th->getLine(),
|
||||||
'hr_name' => $hr['hr_name'] ?? null,
|
'code' => $th->getCode(),
|
||||||
'hr_mobile' => $hr['hr_mobile'] ?? null,
|
'trace' => $th->getTraceAsString(),
|
||||||
'hr_mail' => $hr['hr_mail'] ?? null,
|
'trace_array' => $th->getTrace(), // full array version (optional)
|
||||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
'function' => $th->getTrace()[0]['function'] ?? null,
|
||||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
'class' => $th->getTrace()[0]['class'] ?? null,
|
||||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
];
|
||||||
'pre_client_id' => $pre_client_id ?? 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()
|
public function saveHrAccessData()
|
||||||
@ -7846,7 +8103,4 @@ class ClientController extends AdminController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,7 +60,6 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<div class="container-fluid-min">
|
<div class="container-fluid-min">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@ -135,14 +134,18 @@
|
|||||||
<?php foreach ($pre_policy_data as $key1 => $policies) {
|
<?php foreach ($pre_policy_data as $key1 => $policies) {
|
||||||
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
||||||
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
||||||
if (
|
// if (
|
||||||
in_array($policies['branch_id'].'-'.$policies['policy_no'], $listed_pre)
|
// in_array($policies['branch_id'].'-'.$policies['policy_no'], $listed_pre)
|
||||||
&&
|
// &&
|
||||||
$value['pre_branch_id'] != $policies['branch_id']
|
// $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;
|
continue;
|
||||||
} else {
|
|
||||||
$listed_pre[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="checkbox-item">
|
<div class="checkbox-item">
|
||||||
@ -196,18 +199,22 @@
|
|||||||
<?php foreach ($post_policy_data as $key2 => $policies) {
|
<?php foreach ($post_policy_data as $key2 => $policies) {
|
||||||
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
||||||
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
||||||
if(
|
// if(
|
||||||
in_array($policies['branch_id'].'-'.$policies['policy_no'] , $listed_post)
|
// in_array($policies['branch_id'].'-'.$policies['policy_no'] , $listed_post)
|
||||||
&&
|
// &&
|
||||||
$value['post_branch_id'] != $policies['branch_id']
|
// $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;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$listed_post[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="checkbox-item">
|
<div class="checkbox-item">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user