FIX_HR_LOGIN

This commit is contained in:
VENKATESHWARAN 2025-11-10 18:07:02 +05:30
parent f862f06d61
commit 0502c22ec4
3 changed files with 105 additions and 104 deletions

View File

@ -546,6 +546,7 @@ $routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationCont
// $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity");
$routes->get("employeeRest/getClientDetails", "EmployeeRestController::getClientDetails");
$routes->get("employeeRest/getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");

View File

@ -5661,6 +5661,7 @@ class ClientController extends AdminController
// $employeeController = new EmployeeController();
// $employeeController->truncateFileData('633');
$res = $this->getHrAccessData(4005); dd($res);
// ---------- TICKET SERVICE CONTROLLER --------------------------------------------------------------------------------
@ -7200,6 +7201,7 @@ class ClientController extends AdminController
public function saveHrAccessData()
{
try {
// Step 1: Fetch and decode the JSON data
$client_id = $this->request->getPost('client_id');
$jsonData = $this->request->getPost('json');
@ -7207,11 +7209,7 @@ class ClientController extends AdminController
if (!$data || !is_array($data)) {
log_message('error', 'Invalid or empty JSON in saveHrAccessData: ' . $jsonData);
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Invalid JSON data provided.',
], 400);
return $this->respond(['status' => false,'code' => 400,'message' => 'Invalid JSON data provided.',], 400);
}
$success = [];
@ -7237,15 +7235,13 @@ class ClientController extends AdminController
$post_branch_id = $value['post_branch_id'];
$post_hr_id = $value['post_hr_id'];
$preBranchId = $this->getPreBranchIdByPostBranchId($post_branch_id);
if (!empty($preBranchId)) {
$value['pre_branch_id'] = $preBranchId;
$value['pre_client_id'] = $this->getPreClientIdByPreBranchId($preBranchId);
$value["pre_hr_id"] = $this->getPreHrIdByPreBranchId($preBranchId);
}
// $preBranchId = $this->getPreBranchIdByPostBranchId($post_branch_id);
// if (!empty($preBranchId)) {
// $value['pre_branch_id'] = $preBranchId;
// $value['pre_client_id'] = $this->getPreClientIdByPreBranchId($preBranchId);
// $value["pre_hr_id"] = $this->getPreHrIdByPreBranchId($preBranchId);
// }
// INSERT or UPDATE
if (empty($value['pk']) || (int)$value['pk'] === 0) {
@ -7264,6 +7260,7 @@ class ClientController extends AdminController
}
$success[] = "Updated row with ID {$value['pk']}.";
}
} catch (\Exception $e) {
log_message('error', 'HRAccess Save Error at index ' . $index . ': ' . $e->getMessage());
$errors[] = "Error at index {$index}: " . $e->getMessage();
@ -7654,7 +7651,8 @@ class ClientController extends AdminController
return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200);
}
private function getClientlistFromPre (){
private function getClientlistFromPre()
{
$db2 = \Config\Database::connect('preDB');
$auto_fetch_client_list = $db2->table('clients')
@ -7663,10 +7661,10 @@ class ClientController extends AdminController
->get()->getResultArray() ?? [];
return $auto_fetch_client_list;
}
public function auto_fetch_branch(){
public function auto_fetch_branch()
{
$data = $this->request->getPost();
@ -7695,7 +7693,8 @@ class ClientController extends AdminController
])->setStatusCode(200);
}
public function auto_fetch_branch_details(){
public function auto_fetch_branch_details()
{
$data = $this->request->getPost();
@ -7720,10 +7719,8 @@ class ClientController extends AdminController
'message' => 'branch details found',
'data' => $auto_fetch_branch_details
])->setStatusCode(200);
}
private function updatePreClientBranch($pre_branch_id, $post_branch_id, $operation)
{
@ -7745,7 +7742,8 @@ class ClientController extends AdminController
return true;
}
public function createDefaultMailTemplate($client_id , $client_data){
public function createDefaultMailTemplate($client_id, $client_data)
{
$member_welcome_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_welcome_mail')->get()->getResultArray()[0] ?? [];
@ -7845,8 +7843,6 @@ class ClientController extends AdminController
return $default_templates_inserted ? true : false;
}

View File

@ -547,10 +547,10 @@ class RestAuthenticationController extends AdminController
public function verifyHrWithEmail()
{
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyHrWithEmail: Received payload = " . json_encode($this->request->getJSON() ?? []));
try {
$data = $this->request->getJSON();
$email = $data->email;
$otp = $data->otp;
@ -604,7 +604,17 @@ class RestAuthenticationController extends AdminController
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
}
} catch (\Throwable $th) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return $this->respond(['status' => 'failed','code' => 500,'data' => $th, 'error_data' => $errorData],500);
}
}
@ -678,6 +688,7 @@ class RestAuthenticationController extends AdminController
->join('clients', 'client_branch.client_id = clients.id', 'left')
->where('level_contacts.mobile', $mobile_number )
->where('level_contacts.contact_type', 'client')
->where('is_active', 1)
->findAll();
//set otp value null
$this->hrModel->where('mobile', $mobile_number)->where('otp', $otp)->where('contact_type', 'client')->set(['otp'=>null])->update();
@ -689,6 +700,7 @@ class RestAuthenticationController extends AdminController
->join('clients', 'client_branch.client_id = clients.id', 'left')
->where('level_contacts.email', $email )
->where('level_contacts.contact_type', 'client')
->where('is_active', 1)
->findAll();
//set otp value null
$this->hrModel->where('email', $email)->where('otp', $otp)->where('contact_type', 'client')->set(['otp'=>null])->update();
@ -1949,12 +1961,7 @@ class RestAuthenticationController extends AdminController
public function updateMobileNumber()
{
log_message('error', ' ');
log_message('error', ' ************************************* UPDATE MOBILE START **************************************** ');
log_message('error', ' ');
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateMobileNumber: Function called");
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateMobileNumber: Received payload = " . json_encode($this->request->getJSON() ?? []));
try {
$payload = $this->request->getJSON(true);
@ -2023,9 +2030,6 @@ class RestAuthenticationController extends AdminController
}
} catch (\Throwable $th) {
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateMobileNumber: Exception: " . $th->getMessage());
log_message('error', ' ');
log_message('error', ' ************************************* UPDATE MOBILE END **************************************** ');
log_message('error', ' ');
return $this->respond([
'status' => 'failed',
'code' => 500,