diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index d1286daa..6b91ceb8 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -349,110 +349,114 @@ class EmployeeServiceController extends AdminController unset($excel_data[0]); $relationship = $this->general_relationships; - $employee_data_group_by_family = data_group_by_family($excel_data); - $is_self_available_in_policy_terms = false; - if($policy_details['policy_type_id'] == 3) // GMC parents + if(in_array($file['action'],['inception','addition','dependent_addition']))// the below funcitons are only for I,DA,A { - $temp = $policy_terms['family_floaters']; - $temp = is_array($temp) ? $temp : (is_object($temp) ? (array)$temp : []); - $is_self_available_in_policy_terms = isset($temp['self']) ? true : false; - } - // dd($employee_data_group_by_family); - foreach ($employee_data_group_by_family as $emp_id => $family) - { + $employee_data_group_by_family = data_group_by_family($excel_data); - //if action is DA then get all familiy members,transfrom them into excel array, addd data source as db or excel - if($file['action'] == 'dependent_addition') - { - $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],client_policy_id: $file ['policy_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ]); - // dd(($existing_famility_details)); - //transsform familiy details from db columns to exxcel row with column indexs for checking remaining functionalitites - $existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file); - // dd(array_keys($existing_famility_details[0])); - $family = array_merge($family,$existing_famility_details); - // kint::dump($family); - $family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array - } - // kint::dump($family);//die(); - //check name dup within a family - - if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition') - { - $res = name_dup_check_within_family($family,$file['action']);//in both file data & DB data - // dd($res); - if(count($res)) + $is_self_available_in_policy_terms = false; + if($policy_details['policy_type_id'] == 3) // GMC parents { - foreach($res as $k => $rowid) + $temp = $policy_terms['family_floaters']; + $temp = is_array($temp) ? $temp : (is_object($temp) ? (array)$temp : []); + $is_self_available_in_policy_terms = isset($temp['self']) ? true : false; + } + // dd($employee_data_group_by_family); + foreach ($employee_data_group_by_family as $emp_id => $family) { - array_push($result['error_summary'],7); // dup entry in excel file - $result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Twofold Name found within family"; - } - } - } - //check self availbale in uploaded file - if(($file['action'] == 'inception' || $file['action'] == 'addition') && ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon) - { - // dd('file check'); - $res = check_self_available_in_family($family,$file['action']); - // dd($res); - if(!$res['is_self_found']) - { - array_push($result['error_summary'],14); // Self not found - $result['error_data'][ $res['row_id'] ]['sno']['error'][] = "Self not found in uploaded file"; - } - } + //if action is DA then get all familiy members,transfrom them into excel array, addd data source as db or excel + if($file['action'] == 'dependent_addition') + { + $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],client_policy_id: $file ['policy_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ]); + // dd(($existing_famility_details)); + //transsform familiy details from db columns to exxcel row with column indexs for checking remaining functionalitites + $existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file); + // dd(array_keys($existing_famility_details[0])); + $family = array_merge($family,$existing_famility_details); + // kint::dump($family); + $family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array + } + // kint::dump($family);//die(); + //check name dup within a family - //check self avaialbe either same policy DB level(i.e.) gMC parents - if($file['action'] == 'dependent_addition' || ($policy_details['policy_type_id'] == 3 && !$is_self_available_in_policy_terms)) // 3 is GMC parents as base policy not as dep addon) - { - $self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ]); - // dd($self_details); - if(!count($self_details)) - { - array_push($result['error_summary'],14); // Self not found - $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in System"; - } - } - + if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition') + { + $res = name_dup_check_within_family($family,$file['action']);//in both file data & DB data + // dd($res); + if(count($res)) + { + foreach($res as $k => $rowid) + { + array_push($result['error_summary'],7); // dup entry in excel file + $result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Twofold Name found within family"; + } + } + } - if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception') - { - $res = check_dependent_conflict($family,$policy_terms,$file['action']); - // dd($res); - if(!$res['status']) - { - foreach($res['error_data'] as $key => $value) - { - array_push($result['error_summary'],$value['code']); - $result['error_data'][ $value['row_id'] ][($value['col_name'])]['error'][] = $value['msg']; - } - } - } + //check self availbale in uploaded file + if(($file['action'] == 'inception' || $file['action'] == 'addition') && ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon) + { + // dd('file check'); + $res = check_self_available_in_family($family,$file['action']); + // dd($res); + if(!$res['is_self_found']) + { + array_push($result['error_summary'],14); // Self not found + $result['error_data'][ $res['row_id'] ]['sno']['error'][] = "Self not found in uploaded file"; + } + } - //check dup with empid and name with db - $res = name_and_empid_check_in_db($family,$file); - // dd($res); - // echo '
'; - // print_r($res); - if(count($res['del'])) - { - foreach($res['del'] as $k => $rowid) - { - array_push($result['error_summary'],10); //record not avail for deletion - $result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record Not found "; - } - } - if(count($res['i'])) - { - foreach($res['i'] as $k => $rowid) - { - array_push($result['error_summary'],9); //dup entry - $result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record already exists"; - } - } - } + //check self avaialbe either same policy DB level(i.e.) gMC parents + if($file['action'] == 'dependent_addition' || ($policy_details['policy_type_id'] == 3 && !$is_self_available_in_policy_terms)) // 3 is GMC parents as base policy not as dep addon) + { + $self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ]); + // dd($self_details); + if(!count($self_details)) + { + array_push($result['error_summary'],14); // Self not found + $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in System"; + } + } + + + if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception') + { + $res = check_dependent_conflict($family,$policy_terms,$file['action']); + // dd($res); + if(!$res['status']) + { + foreach($res['error_data'] as $key => $value) + { + array_push($result['error_summary'],$value['code']); + $result['error_data'][ $value['row_id'] ][($value['col_name'])]['error'][] = $value['msg']; + } + } + } + + //check dup with empid and name with db + $res = name_and_empid_check_in_db($family,$file); + // dd($res); + // echo '
'; + // print_r($res); + if(count($res['del'])) + { + foreach($res['del'] as $k => $rowid) + { + array_push($result['error_summary'],10); //record not avail for deletion + $result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record Not found "; + } + } + if(count($res['i'])) + { + foreach($res['i'] as $k => $rowid) + { + array_push($result['error_summary'],9); //dup entry + $result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record already exists"; + } + } + }// end of foreach + }// end of if current action I,DA,A // s($result); // die();