diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 506b33e8..70378281 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1966,7 +1966,8 @@ public function employeesEnrollmentInsert($params) $allowedHighestColumn = end($columns_to_check); $excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']); // print_r($keys);die(); - + //get existing units in the current branch + $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']); //remove header unset($excel_data[0]); // dd($excel_data); @@ -1982,6 +1983,11 @@ public function employeesEnrollmentInsert($params) // dd($key.'-'.count($excel_data)); $value = []; $policy_data = []; + $temp_unit = ''; + if(empty($row[12])) + { + $temp_unit = $existing_units[0]; + } $value['emp_code'] = $row[1]; $value['name'] = $row[2]; @@ -1993,7 +1999,7 @@ public function employeesEnrollmentInsert($params) $value['mobile'] = $row[8]; $value['band'] = $row[10]; $value['basic_pay'] = $row[11]; - $value['unit'] = $row[12]; + $value['unit'] = $temp_unit; $value['family_floater_key'] = null; $value['client_id'] = $file['client_id']; $value['client_branch_id'] = $file['client_branch_id']; diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index ab6299ac..68f348d1 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -2021,6 +2021,12 @@ if(!function_exists('check_unit')) { return array('status' => true); } + else if($temp != $existing_units[0]) + { + return array('status' => false,'error' => 'wrong unit name'); + } + + } if(strtolower($row[5]) == 'self')