Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
22d49c0fbb
@ -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 '<br/>';
|
||||
// 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 '<br/>';
|
||||
// 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();
|
||||
@ -857,9 +861,9 @@ class EmployeeServiceController extends AdminController
|
||||
if($slab_value['si'] == $row[3])
|
||||
{
|
||||
$group_key = rand(100000, 999999);
|
||||
$this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'basic_cover_si','old_value' => $employee_policy['basic_cover_si'],'new_value' => $row[3],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
||||
$this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'premium','old_value' => $employee_policy['premium'],'new_value' => $slab_value['premium'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
||||
$this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'si_enhancement_date','old_value' => null,'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
||||
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'basic_cover_si','old_value' => $employee_policy['basic_cover_si'],'new_value' => $row[3],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
||||
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'premium','old_value' => $employee_policy['premium'],'new_value' => $slab_value['premium'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
||||
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'si_enhancement_date','old_value' => null,'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ use ReflectionClass;
|
||||
|
||||
require_once('../vendor/autoload.php');
|
||||
|
||||
use App\Models\EmployeeModel;
|
||||
|
||||
|
||||
class AuthJWT implements FilterInterface
|
||||
@ -19,27 +20,27 @@ class AuthJWT implements FilterInterface
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
$jwt = $request->getHeader('Authorization');
|
||||
$model = new EmployeeModel();
|
||||
|
||||
if ($jwt) {
|
||||
if (JWTToken::validateJWT($jwt)) {
|
||||
$data = JWTToken::validateJWT($jwt);
|
||||
$data = json_decode($data);
|
||||
|
||||
$id = $data->decoded->id;
|
||||
$user_data = $model->where('id', $id)->first();
|
||||
|
||||
if ($data->status) {
|
||||
// $auth = $request->getHeader("Authorization");
|
||||
// $decodedToken = $data->decoded;
|
||||
|
||||
// $decodedToken->exp += 30;
|
||||
// $newJwt = JWTToken::encode((array)$decodedToken);
|
||||
|
||||
// Set the new JWT in the response headers
|
||||
// $response = service('response');
|
||||
// $response->setHeader('Authorization', $newJwt);
|
||||
if($user_data['token_time_out'] > time()){
|
||||
$data =["token_time_out" => time() + getenv('TOKENTIMEOUT') ];
|
||||
$model->update($id, $data);
|
||||
return true;
|
||||
}else{
|
||||
$data =["token_time_out" => ''];
|
||||
$model->update($id, $data);
|
||||
header('Content-Type: application/json');
|
||||
http_response_code(401);
|
||||
$error = json_encode(["status" => 401, "message" => $data->message]);
|
||||
// $error = json_encode(["status" => 401, "message" => $data->message]);
|
||||
$error = json_encode(["status" => 401, "message" => "Token is Invalid"]);
|
||||
echo $error;
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -12,27 +12,28 @@ use Firebase\JWT\SignatureInvalidException;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use ReflectionClass;
|
||||
|
||||
use App\Models\EmployeeModel;
|
||||
|
||||
|
||||
class JWTToken
|
||||
{
|
||||
public static function encode($data =null)
|
||||
{
|
||||
$secret_Key="secret";
|
||||
$iat = time();
|
||||
$exp = $iat + 180;
|
||||
$request_data = [
|
||||
"iat" => $iat,
|
||||
"exp" => $exp,
|
||||
];
|
||||
if ($data !== null) {
|
||||
$request_data = array_merge($request_data, (array)$data);
|
||||
}
|
||||
try{
|
||||
$token = JWT::encode($request_data ,$secret_Key,'HS512');
|
||||
$secret_Key ="secret";
|
||||
|
||||
return $token;
|
||||
// return ['status' => true,'token' => $token];
|
||||
$request_data = (array)$data;
|
||||
|
||||
try{
|
||||
$token = JWT::encode($request_data ,$secret_Key,'HS512');
|
||||
|
||||
$model = new EmployeeModel();
|
||||
$id = $request_data['id'];
|
||||
$data =[
|
||||
"token_time_out" => time() + getenv('TOKENTIMEOUT')
|
||||
];
|
||||
$model->update($id, $data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
return ['status' => false,'message' => $e->getMessage()];
|
||||
|
||||
@ -199,35 +199,43 @@ if(!function_exists('check_si'))
|
||||
|
||||
if(!$is_si_found && $slab_value['si'] == $received_si) //match si amount
|
||||
{
|
||||
// echo 'found';
|
||||
$is_si_found = true;
|
||||
}
|
||||
|
||||
// check age slab
|
||||
if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob
|
||||
if(in_array(strtoupper($row['current_action']), ['I','A','DA']))
|
||||
{
|
||||
$dob = change_date_format($row[3],'d-M-Y','Y-m-d');
|
||||
// echo $row[3].' - '.$dob;echo '<br>';
|
||||
$currentDateTime = new DateTime();//die();
|
||||
$passedDateTime = new DateTime($dob);
|
||||
$interval = $currentDateTime->diff($passedDateTime);
|
||||
if(!$is_age_slab_found)
|
||||
if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob
|
||||
{
|
||||
if(isset($slab_value['age_from']) && isset($slab_value['age_to']))
|
||||
$dob = change_date_format($row[3],'d-M-Y','Y-m-d');
|
||||
// echo $row[3].' - '.$dob;echo '<br>';
|
||||
$currentDateTime = new DateTime();//die();
|
||||
$passedDateTime = new DateTime($dob);
|
||||
$interval = $currentDateTime->diff($passedDateTime);
|
||||
if(!$is_age_slab_found)
|
||||
{
|
||||
if($slab_value['age_from'] !== null && $slab_value['age_to'] !== null && $slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y && $slab_value['si'] == $received_si)
|
||||
if(isset($slab_value['age_from']) && isset($slab_value['age_to']))
|
||||
{
|
||||
$is_age_slab_found = true;// send true if age slab found
|
||||
if($slab_value['age_from'] !== null && $slab_value['age_to'] !== null && $slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y && $slab_value['si'] == $received_si)
|
||||
{
|
||||
$is_age_slab_found = true;// send true if age slab found
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_age_slab_found = true;// send true if age conditin is not applicable
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_age_slab_found = true;// send true if age conditin is not applicable
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_age_slab_found = true;// send true if age conditin is not applicable
|
||||
}//end of check age slab
|
||||
}
|
||||
}// end of for loop
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,8 @@ class EmployeeModel extends Model
|
||||
"file_id",
|
||||
"is_addon_value",
|
||||
"is_createdby_hr",
|
||||
"client_branch_id"
|
||||
"client_branch_id",
|
||||
"token_time_out"
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
|
||||
Loading…
Reference in New Issue
Block a user