FIX_ENROLMENT_IS_ADD_ON_KEY&DOC_FORMAT&SELF_NOT_AVAIL_ISSUE&GET_VERIFIED_USER_API

This commit is contained in:
velz 2024-12-04 19:55:57 +05:30
parent 83c933837c
commit 04526853fd
3 changed files with 190 additions and 281 deletions

View File

@ -1036,7 +1036,7 @@ class EmployeeServiceController extends AdminController
} }
} }
if(($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms) && ($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0)) // 3 is GMC parents dep addon) if((($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) && ($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0)) // 3 is GMC parents dep addon)
{ {
$res = check_self_available_in_family($family,$file['action']); $res = check_self_available_in_family($family,$file['action']);
if(!$res['is_self_found']) if(!$res['is_self_found'])
@ -1049,7 +1049,7 @@ class EmployeeServiceController extends AdminController
//check self avaialbe either same policy DB level(i.e.) gMC parents //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) 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: trim($emp_id),client_id: $file['client_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ],relationship:['self']); $self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: trim($emp_id),client_id: $file['client_id'],emp_status: ['active','draft','enrolled'],policy_status:['active','draft','enrolled'],client_branch_id:[ $file['client_branch_id'] ],relationship:['self']);
// dd($self_details); // dd($self_details);
if(!count($self_details)) if(!count($self_details))
{ {
@ -1928,7 +1928,6 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
} }
public function employeesEnrollmentInsert($params) public function employeesEnrollmentInsert($params)
{ {
@ -1938,14 +1937,16 @@ public function employeesEnrollmentInsert($params)
$file = $this->fileModel->find($file_id); $file = $this->fileModel->find($file_id);
// dd($file); // dd($file);
$return = []; $return = [];
if (!isset($file)) { if(!isset($file))
{
//file not found in DB //file not found in DB
return array('status' => false, 'msg' => 'file not found in DB'); return array('status' => false, 'msg' => 'file not found in DB');
} }
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name']; $file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
//check physical file //check physical file
if (!file_exists($file_name_with_path)) { if(!file_exists($file_name_with_path))
{
//file not found update status and reason //file not found update status and reason
$message = "Physical file not found"; $message = "Physical file not found";
// echo $message; // echo $message;
@ -1976,17 +1977,21 @@ public function employeesEnrollmentInsert($params)
$notification = $this->notificationModel->where('client_id',$file['client_id'])->where('template_name','member_welcome_mail')->first(); $notification = $this->notificationModel->where('client_id',$file['client_id'])->where('template_name','member_welcome_mail')->first();
// dd($notification); // dd($notification);
$client_details = $this->clientModel->where('id', $file['client_id'])->first(); $client_details = $this->clientModel->where('id', $file['client_id'])->first();
$policy_details = $this->clientPolicyModel->where('id', $file['policy_id'])->first();
// dd($excel_data); // dd($policy_details);
$emp_emails = []; // Initialize an empty array to store employee email.
foreach ($excel_data as $key => $row) { foreach ($excel_data as $key => $row)
{
$is_row_empty = check_row_is_empty_or_null($row); $is_row_empty = check_row_is_empty_or_null($row);
if (!$is_row_empty) { if(!$is_row_empty)
{
$value = []; $value = [];
$policy_data = []; $policy_data = [];
$temp_unit = ''; $temp_unit = '';
if (empty($row[12])) { if(empty($row[12]))
{
$temp_unit = $existing_units[0]; $temp_unit = $existing_units[0];
} }
@ -2005,7 +2010,7 @@ public function employeesEnrollmentInsert($params)
$value['client_id'] = $file['client_id']; $value['client_id'] = $file['client_id'];
$value['client_branch_id'] = $file['client_branch_id']; $value['client_branch_id'] = $file['client_branch_id'];
$value['file_id'] = $file_id; $value['file_id'] = $file_id;
$value['is_addon_value'] = $policy_details['policy_type_id'] == 3 ? 1 : 0;
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model $value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') { if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') {
@ -2022,30 +2027,32 @@ public function employeesEnrollmentInsert($params)
$value['family_floater_key'] = $relation; $value['family_floater_key'] = $relation;
$policy_data['basic_cover_si'] = $row[9]; $policy_data['basic_cover_si'] = $row[9];
$policy_data['date_coverage'] = $row[13]; $policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],'d-M-Y','Y-m-d') : null;
$policy_data['client_policy_id'] = $file['policy_id']; $policy_data['client_policy_id'] = $file['policy_id'];
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']); $employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
unset($value['temp']); unset($value['temp']);
//save employee table //save employee table
// dd($employee['id']); // dd($employee['id']);
if ($employee !== null) { if($employee !== null)
{
$value['updated_by'] = $file['created_by']; $value['updated_by'] = $file['created_by'];
$value['id'] = $employee['id']; $value['id'] = $employee['id'];
$value['emp_status'] = 'draft'; $value['emp_status'] = 'draft';
$log_message = 'Enrollment Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id']; $log_message = 'Enrollment Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id'];
} else { }
else
{
$value['emp_status'] = 'draft'; $value['emp_status'] = 'draft';
$value['created_by'] = $file['created_by']; $value['created_by'] = $file['created_by'];
$log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK '; $log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
} }
$this->employeeModel->save($value); $this->employeeModel->save($value);
if (isset($value['id'])) { if (isset($value['id']))
$emp_id = $value['id']; { $emp_id = $value['id']; }
} else { else { $emp_id = $this->employeeModel->getInsertID();
$emp_id = $this->employeeModel->getInsertID();
$log_message .= $emp_id; $log_message .= $emp_id;
} }
@ -2057,101 +2064,17 @@ public function employeesEnrollmentInsert($params)
//save policy table //save policy table
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]); $employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]);
if (count($employee_policy)) { if(count($employee_policy))
{
$policy_data['updated_by'] = $file['created_by']; $policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id']; $policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft'; $policy_data['status'] = 'draft';
$log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si']; $log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si'];
// echo 'insert policy'; // echo 'insert policy';
} else {
$policy_data['employee_id'] = $emp_id;
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'draft';
$log_message = 'Insert Employee Policy for ' . $value['name'] . '(' . $value['emp_code'] . ') - client policy id -' . $file['policy_id'] . ' - with SI ' . $policy_data['basic_cover_si'];
// echo 'update policy';
} }
else
$this->employeePolicyModel->save($policy_data); {
// $emp_policy_id = $this->employeePolicyModel->getInsertID();
$emp_policy_id = isset($policy_data['id']) ? $policy_data['id'] : $this->employeePolicyModel->getInsertID();
$this->myLogger->logme('error', $log_message);
//save email of self for send mail later
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') {
if (strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "") {
$params['dataToInsert'] = $value; //holds employee master data
$params['notification'] = $notification;
$params['client_data'] = $client_details;
$params['common'] = [
'client_id' => $file['client_id'],
'client_branch_id' => $file['client_branch_id'],
'client_policy_id' => $file['policy_id'],
'employee_policy_id' => $emp_policy_id ?? null,
'employee_id' => $emp_id,
'mail_type' => 'member_welcome_mail',
];
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
// Kint::dump($emp_emails);
// Kint::dump($key.'-'.count($excel_data));
// if mail count is 20 send bulk mail and reset emp_emails variable
// if (count($emp_emails) == 20 || $key == count($excel_data) ) {
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]);
// // echo 'Mail triggered';
// $emp_emails = [];
// }
}
$value['family_floater_key'] = $relation;
$policy_data['basic_cover_si'] = $row[9];
$policy_data['date_coverage'] = $row[13];
$policy_data['client_policy_id'] = $file['policy_id'];
$employee = $this->employeeModel->checkExistingEmployee($value, $file['client_branch_id']);
unset($value['temp']);
//save employee table
// dd($employee['id']);
if ($employee !== null) {
$value['updated_by'] = $file['created_by'];
$value['id'] = $employee['id'];
$value['emp_status'] = 'draft';
$log_message = 'Enrollment Update Employee - ' . $employee['name'] . '(' . $employee['emp_code'] . ') with PK ' . $employee['id'];
} else {
$value['emp_status'] = 'draft';
$value['created_by'] = $file['created_by'];
$log_message = 'Enrollment Insert Employee- ' . $value['name'] . '(' . $value['emp_code'] . ') with PK ';
}
$this->employeeModel->save($value);
if (isset($value['id'])) {
$emp_id = $value['id'];
} else {
$emp_id = $this->employeeModel->getInsertID();
$log_message .= $emp_id;
}
// $emp_id = $this->employeeModel->getInsertID();
// if($emp_id != 0){ $log_message .= $emp_id; }
// else{ $emp_id = $employee['id']; }
$this->myLogger->logme('error', $log_message);
//save policy table
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id, 'client_policy_id' => $file['policy_id']]);
if (count($employee_policy)) {
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
$log_message = 'Update Employee Policy for ' . $value['name'] . '(' . $value['emp_code'] . ') with PK- ' . $employee_policy[0]['id'] . ' client policy ID ' . $employee_policy[0]['client_policy_id'] . ' with SI ' . $policy_data['basic_cover_si'];
// echo 'insert policy';
} else {
$policy_data['employee_id'] = $emp_id; $policy_data['employee_id'] = $emp_id;
$policy_data['client_policy_id'] = $file['policy_id']; $policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by']; $policy_data['created_by'] = $file['created_by'];
@ -2165,37 +2088,21 @@ public function employeesEnrollmentInsert($params)
$this->myLogger->logme('error',$log_message); $this->myLogger->logme('error',$log_message);
//save email of self for send mail later //save email of self for send mail later
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') { if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '')
if (strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "") { {
if(strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "")
{
$params['dataToInsert'] = $value; //holds employee master data $params['dataToInsert'] = $value; //holds employee master data
$params['notification'] = $notification; $params['notification'] = $notification;
$params['client_data'] = $client_details; $params['client_data'] = $client_details;
$params['common'] = [
'client_id' => $file['client_id'],
'client_branch_id' => $file['client_branch_id'],
'client_policy_id' => $file['policy_id'],
'employee_policy_id' => $emp_policy_id ?? null,
'employee_id' => $emp_id,
'mail_type' => 'member_welcome_mail',
];
//store email and mail content via helper to send notification //store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params); $emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
// Kint::dump($emp_emails);
// Kint::dump($key.'-'.count($excel_data));
// if mail count is 20 send bulk mail and reset emp_emails variable
// if (count($emp_emails) == 20 || $key == count($excel_data)) {
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $emp_emails]);
// // echo 'Mail triggered';
// $emp_emails = [];
// }
} }
} }
}// endof if row is empty check }// endof if row is empty check
} //end of for loop } //end of for loop
// dd($emp_emails);
// for bulk mail queue job push // for bulk mail queue job push
if (!empty($emp_emails) && count($emp_emails) > 0) { if (!empty($emp_emails) && count($emp_emails) > 0) {
@ -2215,10 +2122,6 @@ public function employeesEnrollmentInsert($params)
return true; return true;
}//end of employeesEnrollmentInsert
}
}
} }

View File

@ -102,7 +102,13 @@ class RestAuthenticationController extends AdminController
{ {
$employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->first(); $employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->first();
}else{ }else{
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); //$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
$employeeData = $this->employeeModel->where('mobile', $mobile_number)
->where('relationship', 'self')
->where('emp_status !=', 'truncated')
->where('is_active', 1)
->first();
} }

Binary file not shown.