HR api change : GWM
This commit is contained in:
parent
5194da85f7
commit
b0de0e9d84
@ -450,7 +450,7 @@ $routes->post("calculatePremium", "EmployeeRestController::calculatePremium");
|
|||||||
// $routes->post("employeeRest/createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount");
|
// $routes->post("employeeRest/createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount");
|
||||||
// $routes->post("employeeRest/calculatePremium", "EmployeeRestController::calculatePremium");
|
// $routes->post("employeeRest/calculatePremium", "EmployeeRestController::calculatePremium");
|
||||||
|
|
||||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
// $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||||
|
|
||||||
// $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
|
// $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
|
||||||
|
|
||||||
@ -488,7 +488,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
|||||||
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
||||||
$routes->get("getFEContent", "EmployeeRestController::getFEContent");
|
$routes->get("getFEContent", "EmployeeRestController::getFEContent");
|
||||||
$routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
|
$routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
|
||||||
});
|
// });
|
||||||
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
||||||
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
|
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
|
||||||
$routes->post("sendEmail", "EmployeeRestController::send_email");
|
$routes->post("sendEmail", "EmployeeRestController::send_email");
|
||||||
|
|||||||
@ -2724,7 +2724,7 @@ class EmployeeRestController extends AdminController
|
|||||||
->where('client_policy.enrolment_visibility', 1 )
|
->where('client_policy.enrolment_visibility', 1 )
|
||||||
->orderby('client_policy.id' , 'ASC')
|
->orderby('client_policy.id' , 'ASC')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
dd( $ClientPolicyData);
|
||||||
// Retrieve employee and dependents data by passing the employee code
|
// Retrieve employee and dependents data by passing the employee code
|
||||||
$employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
$employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||||
->where('client_id',$this->request->getGet('client_id'))
|
->where('client_id',$this->request->getGet('client_id'))
|
||||||
|
|||||||
@ -75,7 +75,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// employee auth api's start
|
||||||
|
|
||||||
public function verifyEmployeeWithMobileNumber()
|
public function verifyEmployeeWithMobileNumber()
|
||||||
{
|
{
|
||||||
@ -268,6 +268,11 @@ class RestAuthenticationController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// employee auth api's end
|
||||||
|
|
||||||
|
|
||||||
|
// HR auth api's start
|
||||||
|
|
||||||
public function verifyHrWithMobileNumber()
|
public function verifyHrWithMobileNumber()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -295,7 +300,10 @@ class RestAuthenticationController extends AdminController
|
|||||||
public function verifyHrWithEmail()
|
public function verifyHrWithEmail()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$email = $this->request->getJSON()->email;
|
|
||||||
|
$data = $this->request->getJSON();
|
||||||
|
|
||||||
|
$email = $data->email;
|
||||||
|
|
||||||
$HrData = $this->hrModel->where('email', $email)
|
$HrData = $this->hrModel->where('email', $email)
|
||||||
->where('contact_type', 'client')
|
->where('contact_type', 'client')
|
||||||
@ -304,8 +312,47 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
if ($HrData) {
|
if ($HrData) {
|
||||||
|
|
||||||
|
$otp = random_int(100000, 999999);
|
||||||
|
|
||||||
|
$sql = "
|
||||||
|
UPDATE level_contacts
|
||||||
|
SET otp = ?
|
||||||
|
WHERE email = ?
|
||||||
|
AND contact_type = 'client'
|
||||||
|
AND is_active = 1
|
||||||
|
";
|
||||||
|
|
||||||
|
$db = db_connect();
|
||||||
|
$update = $db->query($sql, [$otp, $email]);
|
||||||
|
|
||||||
|
if($update)
|
||||||
|
{
|
||||||
|
$data->otp = $otp;
|
||||||
|
$this->callThirdPartyAPI($data, 'updateHROTP');
|
||||||
|
|
||||||
|
$common = [
|
||||||
|
'login_type' => 'HR login',
|
||||||
|
'login_email' => $email,
|
||||||
|
'mail_type' => 'otp_mail'
|
||||||
|
];
|
||||||
|
$subject = 'Nhance user verification - OTP';
|
||||||
|
$mail_content = $otp . ' is your verification code for Nhance.';
|
||||||
|
$res = MailHelper::send_email(['mail' => $email, '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"];
|
$result = ['user_verification' => true, 'message' => "Verified Successfully"];
|
||||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
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 {
|
||||||
|
|
||||||
|
$result = ['user_verification' => false, 'message' => "Verification failed , try again"];
|
||||||
|
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Call the third-party API function
|
// Call the third-party API function
|
||||||
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyHrWithEmail');
|
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyHrWithEmail');
|
||||||
@ -320,11 +367,23 @@ class RestAuthenticationController extends AdminController
|
|||||||
public function getVerifiedHrData()
|
public function getVerifiedHrData()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
// mobile number
|
||||||
$otp_verification = $this->request->getJSON()->otp_verification;
|
$otp_verification = isset($this->request->getJSON()->otp_verification) ? $this->request->getJSON()->otp_verification : null;
|
||||||
|
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||||
|
// email id
|
||||||
|
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
|
||||||
|
$email = isset($this->request->getJSON()->email) ? $this->request->getJSON()->email : null;
|
||||||
|
|
||||||
|
if (isset($mobile_number))
|
||||||
|
{
|
||||||
|
$hrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first();
|
||||||
|
}else{
|
||||||
|
$hrData = $this->hrModel->where('email', $email)->where('contact_type', 'client')->where('otp', $otp)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($hrData && $otp_verification == true || $hrData && isset($this->request->getJSON()->otp) )
|
||||||
|
{
|
||||||
|
|
||||||
$hrData = $this->hrModel->where('mobile', $mobile_number)->first();
|
|
||||||
if ($hrData && $otp_verification == true) {
|
|
||||||
$auth = HttpRequestHelper::getRequestInfo();
|
$auth = HttpRequestHelper::getRequestInfo();
|
||||||
if ($auth) {
|
if ($auth) {
|
||||||
$data = [
|
$data = [
|
||||||
@ -340,11 +399,25 @@ class RestAuthenticationController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(isset($this->request->getJSON()->mobile_number)){
|
||||||
|
|
||||||
$hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
|
$hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
|
||||||
->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left')
|
->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left')
|
||||||
->where('level_contacts.mobile', $mobile_number )
|
->where('level_contacts.mobile', $mobile_number )
|
||||||
|
->where('level_contacts.contact_type', 'client')
|
||||||
->find();
|
->find();
|
||||||
|
|
||||||
|
}else if(isset($this->request->getJSON()->otp)){
|
||||||
|
|
||||||
|
$this->hrModel->where('email', $email)->where('otp', $otp)->where('contact_type', 'client')->set(['otp'=>null])->update();
|
||||||
|
|
||||||
|
$hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
|
||||||
|
->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left')
|
||||||
|
->where('level_contacts.email', $email )
|
||||||
|
->where('level_contacts.contact_type', 'client')
|
||||||
|
->find();
|
||||||
|
}
|
||||||
|
|
||||||
$result = JWTToken::encode($hrData['0']);
|
$result = JWTToken::encode($hrData['0']);
|
||||||
|
|
||||||
// Call the third-party API function
|
// Call the third-party API function
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user