diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 22b1b6a..bafc79c 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -2201,7 +2201,9 @@ class EmployeeController extends AdminController //UPDATE EMPLOYEE public function update_emp_data() - { + { + helper('utility_helper'); + $data = $this->request->getPost(); // print_rr($data);die(); // $data['dob'] = date('Y-m-d', strtotime($data['dob'])); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 6afa1af..e000e93 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -113,66 +113,65 @@ class RestAuthenticationController extends AdminController { try { $email = $this->request->getJSON()->email; - - $employeeData = $this->employeeModel->select('employees.relationship,EP.employee_id') - ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner') - ->where('employees.is_active', 1) - ->where('employees.relationship', 'self') - ->where('employees.emp_status !=', 'truncated') - ->where('employees.email_corporate', $email) - ->where('EP.is_active', 1) - ->whereIn('EP.status', ['draft', 'enrolled']) - ->first(); - - if (isset($employeeData['employee_id'])) - { + + $employeeData = $this->employeeModel->select(' + employees.relationship, + EP.employee_id, + employees.client_id, + employees.client_branch_id, + employees.email_corporate + + ') + ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner') + ->where('employees.is_active', 1) + ->where('employees.relationship', 'Self') + ->where('employees.emp_status !=', 'truncated') + ->where('employees.email_corporate', $email) + ->where('EP.is_active', 1) + ->whereIn('EP.status', ['draft', 'enrolled']) + ->first(); + + if (isset($employeeData['employee_id'])) { $otp = random_int(100000, 999999); - $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self') - ->where('is_active', 1)->set(array('otp' => $otp )) - ->update(); - if($update) - { + $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self') + ->where('is_active', 1)->set(array('otp' => $otp)) + ->update(); + if ($update) { $common = [ 'client_id' => $employeeData['client_id'], 'client_branch_id' => $employeeData['client_branch_id'], 'client_policy_id' => null, 'employee_policy_id' => null, - 'employee_id' => $employeeData['id'], + 'employee_id' => $employeeData['employee_id'], 'mail_type' => 'otp_mail', - ]; + ]; $subject = 'Nhance user verification - OTP'; - $mail_content = $otp.' is your verification code for Nhance.'; - $res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject ,'common'=>$common ,'message' => $mail_content]); + $mail_content = $otp . ' is your verification code for Nhance.'; + $res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject, 'common' => $common, 'message' => $mail_content]); $this->myLogger->logme("info", $res); - if(json_decode($res)->status == 'success') - { - $result = ['user_verification' => true ,'message' => "Verified Successfully"]; - return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); - - }else{ - $result = ['user_verification' => false , 'message' => "Mail sending failed , try again"]; - return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200); + if (json_decode($res)->status == 'success') { + $result = ['user_verification' => true, 'message' => "Verified Successfully"]; + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); + } else { + $result = ['user_verification' => false, 'message' => "Mail sending failed , try again"]; + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); } + } else { - }else{ - - $result = ['user_verification' => false , 'message' => "Verification failed , try again"]; - return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200); - + $result = ['user_verification' => false, 'message' => "Verification failed , try again"]; + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); } - - } else { // Call the third-party API function - return $this->callThirdPartyAPI($this->request->getJSON(),'verifyEmployeeEmailId'); + return $this->callThirdPartyAPI($this->request->getJSON(), 'verifyEmployeeEmailId'); } } catch (\Throwable $th) { - return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); + return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500); } }