CHANGE_HR_API_AND_SAVE_MPIN_API : RV
This commit is contained in:
parent
d3506365ca
commit
f045e21c3a
@ -358,7 +358,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields');
|
||||
$routes->get('removeMultiFile', 'LeadsController::removeMultiFile');
|
||||
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
|
||||
$routes->get('constructHrAccessData', 'ClientController::constructHrAccessData');
|
||||
$routes->get('viewHrAccessData', 'ClientController::viewHrAccessData');
|
||||
$routes->post('saveHrAccessData', 'ClientController::saveHrAccessData');
|
||||
});
|
||||
|
||||
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
|
||||
|
||||
@ -2316,7 +2316,7 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
|
||||
|
||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type, client_policy.policy_no as policy_no, client_policy.insurer_id as insurer_id ')
|
||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type, client_policy.policy_no as policy_no, client_policy.insurer_id as insurer_id, DATE_FORMAT(client_policy.policy_end_date, "%d-%m-%Y") AS policy_expiry_date ')
|
||||
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
||||
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') )
|
||||
->where('client_policy.is_active', 1 )
|
||||
|
||||
@ -187,44 +187,140 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
// public function updateEmpMPIN()
|
||||
// {
|
||||
// $requestData = $this->request->getJSON();
|
||||
// print_r($requestData); die;
|
||||
// $mobile_number = $requestData->mobile_number ?? null;
|
||||
// $email_id = $requestData->email_id ?? null;
|
||||
// $new_mpin = $requestData->new_mpin ?? $requestData->mpin ?? null;
|
||||
// $old_mpin = $requestData->old_mpin ?? null;
|
||||
// $is_mpin_skipped = $requestData->is_mpin_skipped ?? null;
|
||||
// $is_biometric_enabled = $requestData->is_biometric_enabled ?? null;
|
||||
|
||||
// if (!$new_mpin) {
|
||||
// return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']);
|
||||
// }
|
||||
|
||||
// $query = $this->employeeModel->where('relationship', 'self');
|
||||
|
||||
// if ($mobile_number) {
|
||||
// $query->where('mobile', $mobile_number);
|
||||
// } elseif ($email_id) {
|
||||
// $query->where('email_corporate', $email_id);
|
||||
// } else {
|
||||
// return $this->response->setJSON(['status' => false, 'message' => 'Mobile number or Email ID is required.']);
|
||||
// }
|
||||
|
||||
// if (!empty($old_mpin)) {
|
||||
// $query->where('mpin', $old_mpin);
|
||||
// }
|
||||
|
||||
// // Fetch employee data
|
||||
// $employeeData = $query->first();
|
||||
|
||||
// if (!$employeeData) {
|
||||
// return $this->response->setJSON(['status' => false, 'message' => 'Employee not found or invalid MPIN.']);
|
||||
// }
|
||||
|
||||
// if(!empty($is_mpin_skipped) && !empty($is_biometric_enabled)){
|
||||
// $mpin_data_to_updata = [
|
||||
// 'mpin' => $new_mpin,
|
||||
// 'is_mpin_skipped' => $is_mpin_skipped,
|
||||
// 'is_biometric_enabled' => $is_biometric_enabled
|
||||
// ];
|
||||
// }else{
|
||||
// $mpin_data_to_updata = ['mpin' => $new_mpin];
|
||||
// }
|
||||
|
||||
// // Update MPIN
|
||||
// $updated = $this->employeeModel->update($employeeData['id'], $mpin_data_to_updata);
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
public function updateEmpMPIN()
|
||||
{
|
||||
$requestData = $this->request->getJSON();
|
||||
$mobile_number = $requestData->mobile_number ?? null;
|
||||
$email_id = $requestData->email_id ?? null;
|
||||
$new_mpin = $requestData->new_mpin ?? $requestData->mpin ?? null;
|
||||
$old_mpin = $requestData->old_mpin ?? null;
|
||||
|
||||
if (!$new_mpin) {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']);
|
||||
try {
|
||||
log_message('info', 'MPIN update request received.');
|
||||
|
||||
$requestData = $this->request->getJSON();
|
||||
log_message('debug', 'Request data: ' . json_encode($requestData));
|
||||
|
||||
$mobile_number = $requestData->mobile_number ?? null;
|
||||
$email_id = $requestData->email_id ?? null;
|
||||
$new_mpin = $requestData->new_mpin ?? $requestData->mpin ?? null;
|
||||
$old_mpin = $requestData->old_mpin ?? null;
|
||||
$is_mpin_skipped = $requestData->is_mpin_skipped ?? null;
|
||||
$is_biometric_enabled = $requestData->is_biometric_enabled ?? null;
|
||||
|
||||
if (!$new_mpin) {
|
||||
log_message('warning', 'MPIN is missing.');
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']);
|
||||
}
|
||||
|
||||
$query = $this->employeeModel->where('relationship', 'self');
|
||||
log_message('info', 'Query initialized with relationship=self');
|
||||
|
||||
if ($mobile_number) {
|
||||
$query->where('mobile', $mobile_number);
|
||||
log_message('info', "Filtering by mobile number: {$mobile_number}");
|
||||
} elseif ($email_id) {
|
||||
$query->where('email_corporate', $email_id);
|
||||
log_message('info', "Filtering by email ID: {$email_id}");
|
||||
} else {
|
||||
log_message('warning', 'Neither mobile number nor email ID provided.');
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Mobile number or Email ID is required.']);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$query->where('mpin', $old_mpin);
|
||||
log_message('info', "Verifying old MPIN: {$old_mpin}");
|
||||
}
|
||||
|
||||
$employeeData = $query->first();
|
||||
log_message('debug', 'Employee lookup result: ' . json_encode($employeeData));
|
||||
|
||||
if (!$employeeData) {
|
||||
log_message('warning', 'Employee not found or invalid old MPIN.');
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Employee not found or invalid MPIN.']);
|
||||
}
|
||||
|
||||
$mpin_data_to_update = ['mpin' => $new_mpin];
|
||||
|
||||
if ($is_mpin_skipped != null && $is_biometric_enabled != null) {
|
||||
$mpin_data_to_update['is_mpin_skipped'] = $is_mpin_skipped;
|
||||
$mpin_data_to_update['is_biometric_enabled'] = $is_biometric_enabled;
|
||||
log_message('info', 'Updating MPIN, MPIN skip flag, and biometric flag.');
|
||||
} else {
|
||||
log_message('info', 'Updating MPIN only.');
|
||||
}
|
||||
|
||||
$updated = $this->employeeModel->update($employeeData['id'], $mpin_data_to_update);
|
||||
|
||||
if ($updated) {
|
||||
log_message('info', "MPIN updated successfully for employee ID: {$employeeData['id']}");
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
'message' => 'MPIN updated successfully.'
|
||||
]);
|
||||
} else {
|
||||
log_message('error', "Failed to update MPIN for employee ID: {$employeeData['id']}");
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Failed to update MPIN.'
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
log_message('critical', 'Exception in updateEmpMPIN: ' . $e->getMessage());
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Unexpected error occurred.',
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
$query = $this->employeeModel->where('relationship', 'self');
|
||||
|
||||
if ($mobile_number) {
|
||||
$query->where('mobile', $mobile_number);
|
||||
} elseif ($email_id) {
|
||||
$query->where('email_corporate', $email_id);
|
||||
} else {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Mobile number or Email ID is required.']);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$query->where('mpin', $old_mpin);
|
||||
}
|
||||
|
||||
// Fetch employee data
|
||||
$employeeData = $query->first();
|
||||
|
||||
if (!$employeeData) {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Employee not found or invalid MPIN.']);
|
||||
}
|
||||
|
||||
// Update MPIN
|
||||
$updated = $this->employeeModel->update($employeeData['id'], ['mpin' => $new_mpin]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user