From 1b3270aae0a711f9d7cf7622dce56d8a0c4fe5d1 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 10 Nov 2025 14:14:17 +0530 Subject: [PATCH 01/30] FEAT_PASSWORD_LOGIN_API --- app/Config/Routes.php | 7 +- .../RestAuthenticationController.php | 383 +++++++++--------- app/Models/EmployeeModel.php | 1 + 3 files changed, 203 insertions(+), 188 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index bbddfdec..af9b67e1 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -506,6 +506,7 @@ $routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController $routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationController::verifyEmployeeWithEmailId"); $routes->post("/employeeRest/updateEmpOTP", "RestAuthenticationController::updateEmpOTP"); +// MPIN api's $routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin"); $routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin"); $routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin"); @@ -513,8 +514,12 @@ $routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpi $routes->post("/employeeRest/updateEmpMPIN", "RestAuthenticationController::updateEmpMPIN"); $routes->post("employeeRest/forgotMPIN", "RestAuthenticationController::forgotMPIN"); $routes->post("employeeRest/updateMobileNumber", "RestAuthenticationController::updateMobileNumber"); -// $routes->post("/employeeRest/saveMpin", "RestAuthenticationController::saveMpin"); +// PASSWORD api's +$routes->post("employeeRest/savePassword", "RestAuthenticationController::savePassword"); +$routes->post("employeeRest/changePassword", "RestAuthenticationController::changePassword"); +$routes->post("employeeRest/verifyPassword", "RestAuthenticationController::verifyPassword"); +$routes->post("employeeRest/verifyOtp", "RestAuthenticationController::verifyOtp"); //HR login api's $routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 11b1a8fc..c5630624 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -1515,9 +1515,116 @@ class RestAuthenticationController extends AdminController $email_id = $payload->email_id ?? null; $client_id = $payload->client_id ?? null; $plain_password = $payload->password ?? null; + $confirm_password = $payload->confirm_password ?? null; - if (empty($plain_password)) { - return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Password cannot be empty'], 400); + if (empty($plain_password) || empty($confirm_password)) { + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Both password cannot be empty'], 400); + } + + if($plain_password !== $confirm_password){ + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Password and confirm password not matched'], 400); + } + + // Build employee query + if ($mobile_number) { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.mobile', $mobile_number) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active', 'expired']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active', 'expired']); + if (!empty($client_id)) $builder->where('employees.client_id', $client_id); + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } else { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.email_corporate', $email_id) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active', 'expired']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active', 'expired']); + if (!empty($client_id)) $builder->where('employees.client_id', $client_id); + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } + + $lastQuery = $this->employeeModel->db->getLastQuery(); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Last Executed Query: " . $lastQuery); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: employeeData: " . json_encode($employeeData ?? [])); + + + if ($employeeData) { + $id = $employeeData['id']; + $hashedPassword = password_hash($plain_password, PASSWORD_DEFAULT); + + $updateData = [ + 'password' => $hashedPassword, + ]; + + $updated = $this->employeeModel->where('id', $id)->set($updateData)->update(); + + if ($updated) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Password saved successfully"); + $result = ['user_verification' => true, 'message' => "Password saved successfully"]; + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); + } else { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Password save failed"); + $result = ['user_verification' => true, 'message' => "Password not saved"]; + return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $result], 200); + } + } else { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Employee not found"); + $result = ['user_verification' => false, 'message' => "User not found"]; + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); + } + } catch (\Throwable $th) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString()); + $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, 'message' => $th->getMessage(), 'errorData' => $errorData], 500); + } + } + + public function changePassword() + { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Received payload = " . json_encode($this->request->getJSON() ?? [])); + + try { + + $payload = $this->request->getJSON(true); + $mobile_number = $payload['mobile_number'] ?? null; + $email_id = $payload['email_id'] ?? null; + $client_id = $payload['client_id'] ?? null; + $old_password = $payload['old_password'] ?? null; + $new_password = $payload['new_password'] ?? null; + $confirm_password = $payload['confirm_password'] ?? null; + + if (!$mobile_number && !$email_id) { + return $this->respond(['status' => 'failed','code' => 400,'message' => 'Mobile number or Email ID is required'], 400); + } + + if (empty($new_password) || empty($confirm_password) || empty($old_password)) { + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'old_password , New password and Confirm password are required' ], 400); + } + + if($new_password !== $confirm_password){ + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'New password and confirm password not matched'], 400); } // Build employee query @@ -1555,161 +1662,57 @@ class RestAuthenticationController extends AdminController $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Last Executed Query: " . $lastQuery); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: employeeData: " . json_encode($employeeData ?? [])); - if ($employeeData) { - $id = $employeeData['id']; - $hashedPassword = password_hash($plain_password, PASSWORD_DEFAULT); + if ($employeeData && password_verify($old_password, $employeeData['password'])) { - $updateData = [ - 'password' => $hashedPassword, - ]; + // Hash new password + // $newHashedPassword = password_hash($new_password, PASSWORD_DEFAULT); + $newHashedPassword = $new_password; - $updated = $this->employeeModel->where('id', $id)->set($updateData)->update(); + // Update password and clear OTP + $updated = $this->employeeModel->update($employeeData['id'], [ + 'password' => $newHashedPassword, + ]); if ($updated) { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Password saved successfully"); - $result = ['user_verification' => true, 'message' => "Password saved successfully"]; - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Password updated successfully"); + return $this->respond(['status' => 'success','code' => 200,'message' => 'Password changed successfully'], 200); } else { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Password save failed"); - $result = ['user_verification' => true, 'message' => "Password not saved"]; - return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $result], 200); + return $this->respond(['status' => 'failed','code' => 500,'message' => 'Failed to update password' ], 500); } - } else { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Employee not found"); - $result = ['user_verification' => false, 'message' => "User not found"]; - return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); - } - } catch (\Throwable $th) { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString()); - return $this->respond(['status' => 'failed', 'code' => 500, 'message' => $th->getMessage()], 500); - } - } - public function changePassword() - { - log_message('error', ' '); - log_message('error', ' ************************************* CHANGE PASSWORD START **************************************** '); - log_message('error', ' '); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Function called"); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Received payload = " . json_encode($this->request->getJSON() ?? [])); - - try { - $payload = $this->request->getJSON(true); - - $mobile_number = $payload['mobile_number'] ?? null; - $email_id = $payload['email_id'] ?? null; - $client_id = $payload['client_id'] ?? null; - $otp = $payload['otp'] ?? null; - $new_password = $payload['new_password'] ?? null; - - if (empty($otp) || empty($new_password)) { - return $this->respond([ - 'status' => 'failed', - 'code' => 400, - 'message' => 'OTP and new password are required' - ], 400); - } - - // Fetch employee details - $builder = $this->employeeModel - ->select('employees.*') - ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.relationship', 'Self') - ->where('employees.is_active', 1) - ->whereIn('employees.emp_status', ['active']) - ->where('employee_polices.is_active', 1) - ->whereIn('employee_polices.status', ['active']); - - if (!empty($client_id)) $builder->where('employees.client_id', $client_id); - - if ($mobile_number) { - $builder->where('employees.mobile', $mobile_number); - } elseif ($email_id) { - $builder->where('employees.email_corporate', $email_id); - } else { - return $this->respond([ - 'status' => 'failed', - 'code' => 400, - 'message' => 'Mobile number or Email ID is required' - ], 400); - } - - $employeeData = $builder->orderBy('employees.id', 'desc')->first(); - - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: employeeData: " . json_encode($employeeData ?? [])); - - if (!$employeeData) { + }else{ return $this->respond(['status' => 'failed', 'code' => 404, 'message' => 'User not found'], 404); } - // Check OTP validity (assuming fields: otp, otp_expiry exist) - if (empty($employeeData['otp']) || $employeeData['otp'] != $otp) { - return $this->respond(['status' => 'failed', 'code' => 401, 'message' => 'Invalid OTP'], 200); - } - - if (!empty($employeeData['otp_expiry']) && strtotime($employeeData['otp_expiry']) < time()) { - return $this->respond(['status' => 'failed', 'code' => 401, 'message' => 'OTP expired'], 200); - } - - // Hash new password - $newHashedPassword = password_hash($new_password, PASSWORD_DEFAULT); - - // Update password and clear OTP - $updated = $this->employeeModel->update($employeeData['id'], [ - 'password' => $newHashedPassword, - 'otp' => null, - ]); - - if ($updated) { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Password updated successfully"); - log_message('error', ' '); - log_message('error', ' ************************************* CHANGE PASSWORD END **************************************** '); - log_message('error', ' '); - - return $this->respond([ - 'status' => 'success', - 'code' => 200, - 'message' => 'Password changed successfully' - ], 200); - } else { - return $this->respond([ - 'status' => 'failed', - 'code' => 500, - 'message' => 'Failed to update password' - ], 500); - } - } catch (\Throwable $th) { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Exception: " . $th->getMessage()); - log_message('error', ' '); - log_message('error', ' ************************************* CHANGE PASSWORD END **************************************** '); - log_message('error', ' '); return $this->respond(['status' => 'failed', 'code' => 500, 'message' => $th->getMessage()], 500); } } public function verifyPassword() { - log_message('error', ' '); - log_message('error', ' ************************************* POST START **************************************** '); - log_message('error', ' '); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - Verify Password: Function called"); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Received payload = " . json_encode($this->request->getJSON() ?? [])); try { - $requestData = $this->request->getJSON(true); + $requestData = $this->request->getJSON(true); $mobile_number = $requestData['mobile_number'] ?? null; $email_id = $requestData['email_id'] ?? null; $password = $requestData['password'] ?? null; $client_id = $requestData['client_id'] ?? null; + if(!$mobile_number && !$email_id){ + return $this->respond(['status' => 'failed', 'code' => 400, 'data' => "", 'message' => 'Mobile number or Email ID is required'], 400); + } + if (!$password) { return $this->respond(['status' => 'failed', 'code' => 400, 'data' => "", 'message' => 'Password is required'], 400); } // 🔹 Fetch employee data if ($mobile_number) { + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') @@ -1725,7 +1728,9 @@ class RestAuthenticationController extends AdminController } $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + } elseif ($email_id) { + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') @@ -1741,9 +1746,8 @@ class RestAuthenticationController extends AdminController } $employeeData = $builder->orderBy('employees.id', 'desc')->first(); - } else { - return $this->respond(['status' => 'failed', 'code' => 400, 'data' => "", 'message' => 'Mobile number or Email ID is required'], 400); - } + + } $lastQuery = $this->employeeModel->db->getLastQuery(); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Last Executed Query: " . $lastQuery); @@ -1770,11 +1774,8 @@ class RestAuthenticationController extends AdminController $employeeData['token_type'] = "post"; $token = JWTToken::encode($employeeData); - log_message('error', ' '); - log_message('error', ' ************************************* POST END **************************************** '); - log_message('error', ' '); - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $token], 200); + } else { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Invalid password or employee not found"); log_message('error', ' '); @@ -1783,6 +1784,7 @@ class RestAuthenticationController extends AdminController return $this->respond(['status' => 'failed', 'code' => 404, 'data' => "", 'message' => 'Invalid password'], 200); } + } catch (\Exception $e) { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine()); log_message('error', ' '); @@ -1792,75 +1794,82 @@ class RestAuthenticationController extends AdminController } } - public function sendChangePasswordOTP() + public function verifyOtp() { - log_message('error', ' '); - log_message('error', ' ************************************* SEND OTP START **************************************** '); - log_message('error', ' '); - - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: Function called"); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: Received payload = " . json_encode($this->request->getJSON() ?? [])); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyOtp: Received payload = " . json_encode($this->request->getJSON() ?? [])); try { - $requestData = $this->request->getJSON(true); + $requestData = $this->request->getJSON(true); + $mobile_number = $requestData['mobile_number'] ?? null; $email_id = $requestData['email_id'] ?? null; $client_id = $requestData['client_id'] ?? null; + $otp = $requestData['otp'] ?? null; - if (!$email_id) { - return $this->respond(['status' => 'failed', 'code' => 400, 'data' => "", 'message' => 'Email ID is required'], 400); + if(!$mobile_number && !$email_id){ + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Mobile number or Email ID is required'], 400); } - // Get employee details - $builder = $this->employeeModel - ->select('employees.id, employees.mobile, employees.email_corporate, employees.client_id') - ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.is_active', 1) - ->whereIn('employees.emp_status', ['active']) - ->where('employee_polices.is_active', 1) - ->whereIn('employee_polices.status', ['active']) - ->where('employees.relationship', 'Self'); - - if (!empty($client_id)) { - $builder->where('employees.client_id', $client_id); + if (!$otp) { + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'OTP is required'], 400); } - if ($email_id) { - $builder->where('employees.email_corporate', $email_id); + // 🔹 Fetch employee data + if ($mobile_number) { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.mobile', $mobile_number) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } else { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.email_corporate', $email_id) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } + + $lastQuery = $this->employeeModel->db->getLastQuery(); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Last Executed Query: " . $lastQuery); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: employeeData: " . json_encode($employeeData ?? [])); + + // 🔹 Verify otp + if ($employeeData && $employeeData['otp'] == $otp) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyOtp: OTP Verified employee found"); + $this->employeeModel->where('id', $employeeData['id'])->where('otp', $otp)->where('relationship', 'self')->set(['otp'=>null])->update(); + return $this->respond(['status' => 'success', 'code' => 200, 'message' => "OTP verified succesfully"], 200); + } else { + + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyOtp: OTP verification failed, OTP not found in the post db"); + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => "OTP verification failed"], 200); } - - $employeeData = $builder->orderBy('employees.id', 'desc')->first(); - - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: Employee Data: " . json_encode($employeeData ?? [])); - - if (!$employeeData) { - return $this->respond(['status' => 'failed', 'code' => 404, 'data' => "", 'message' => 'Employee not found'], 404); - } - - // Generate 6-digit OTP - $otp = rand(100000, 999999); - - // Save OTP to DB (assuming 'otp' and 'otp_expiry' columns exist) - $this->employeeModel->update($employeeData['id'], [ - 'otp' => $otp, - ]); - - // Send OTP via SMS or Email (you can replace with your actual helper) - if ($email_id) { - // Example: MailHelper::sendMail($email_id, 'Password Change OTP', "Your OTP is {$otp}"); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: OTP {$otp} sent to email {$email_id}"); - } - - log_message('error', ' '); - log_message('error', ' ************************************* SEND OTP END **************************************** '); - log_message('error', ' '); - - return $this->respond(['status' => 'success', 'code' => 200, 'data' => ['otp_sent_to' => $email_id], 'message' => 'OTP sent successfully'], 200); + } catch (\Exception $e) { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine()); - log_message('error', ' '); - log_message('error', ' ************************************* SEND OTP END **************************************** '); - log_message('error', ' '); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyOtp: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine()); return $this->respond(['status' => 'failed', 'code' => 500, 'data' => "", 'message' => $e->getMessage()], 500); } } diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 1416c082..7f210ca7 100755 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -45,6 +45,7 @@ class EmployeeModel extends Model "mpin", "is_mpin_skipped", "is_biometric_enabled", + "password", ]; // Callbacks From f862f06d617fc9b279fce9946e3f3add01829f72 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 10 Nov 2025 14:37:51 +0530 Subject: [PATCH 02/30] FEAT_CHECK_PASS --- app/Config/Routes.php | 1 + .../RestAuthenticationController.php | 71 +++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index af9b67e1..0c0be495 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -520,6 +520,7 @@ $routes->post("employeeRest/savePassword", "RestAuthenticationController::savePa $routes->post("employeeRest/changePassword", "RestAuthenticationController::changePassword"); $routes->post("employeeRest/verifyPassword", "RestAuthenticationController::verifyPassword"); $routes->post("employeeRest/verifyOtp", "RestAuthenticationController::verifyOtp"); +$routes->post("employeeRest/checkPassword", "RestAuthenticationController::checkPassword"); //HR login api's $routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index c5630624..702d43bf 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -1874,6 +1874,77 @@ class RestAuthenticationController extends AdminController } } + public function checkPassword() + { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Request payload = " . json_encode($this->request->getJSON() ?? [])); + + try { + + $payload = $this->request->getJSON() ?? []; + $mobile_number = $payload->mobile_number ?? null; + $email_id = $payload->email_id ?? null; + + if(!$mobile_number && !$email_id){ + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Mobile number or Email ID is required'], 400); + } + + // 🔹 Fetch employee data + if ($mobile_number) { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.mobile', $mobile_number) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } else { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.email_corporate', $email_id) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } + + $lastQuery = $this->employeeModel->db->getLastQuery(); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Last Executed Query: " . $lastQuery); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: employeeData: " . json_encode($employeeData ?? [])); + + if ($employeeData && $employeeData["password"] != null) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Mpin - Exist"); + return $this->respond(['status' => 'success','code' => 200,'data' => "", 'message' => "Password - exist"],200); + } else { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Password - not found in PRE so call the thirdpartapi to the POST to check the MPIN"); + return $this->respond(['status' => 'failed','code' => 200,'data' => "", 'message' => "Password - not exist"],200); + } + + } catch (\Exception $e) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString()); + return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => $e->getMessage()],500); + } + } + // -------------- EMP MOBILE NUMBER UPDATE API'S ------------------------------------------------------------------------------------------------------------- public function updateMobileNumber() From 1b085f4c5605aee4a5fc32ee00d1ad0d84b8c7b7 Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Mon, 10 Nov 2025 17:45:00 +0530 Subject: [PATCH 03/30] FIX_BDS common Issues --- app/Views/bds_renewal_report_list.php | 7 ++ app/Views/outstanding_report_list.php | 44 +++++++++---- app/Views/report_bds_filter.php | 93 +++++++++++++++++---------- 3 files changed, 96 insertions(+), 48 deletions(-) diff --git a/app/Views/bds_renewal_report_list.php b/app/Views/bds_renewal_report_list.php index a3147bd1..9d44a633 100644 --- a/app/Views/bds_renewal_report_list.php +++ b/app/Views/bds_renewal_report_list.php @@ -7,6 +7,13 @@ table.dataTable tbody td { padding: 4px 4px !important; } + .column-header { + margin-right: 10px; /* Adjust this value as needed */ + } + + table[data-custom-table-css="table"].dataTable thead th { + padding-right: 20px !important; + }
diff --git a/app/Views/outstanding_report_list.php b/app/Views/outstanding_report_list.php index 203c4151..53b807d9 100644 --- a/app/Views/outstanding_report_list.php +++ b/app/Views/outstanding_report_list.php @@ -21,6 +21,18 @@ .center-align-input { text-align: center; } + + .column-header { + margin-right: 10px; /* Adjust this value as needed */ + } + + /* Center align header text and icons */ + table[data-custom-table-css="table"].dataTable thead th { + padding-top: 3px !important; + padding-bottom: 4px !important; + padding-right: 15px !important; + padding-left: 15px !important; + }
@@ -107,21 +119,21 @@
- +
- + - - - - - - - - - - + + + + + + + + + + @@ -213,8 +225,12 @@ ] }], language: { - search: "_INPUT_", - searchPlaceholder: "Search..." + search: ` +
+ _INPUT_ + +
`, + searchPlaceholder: "Search" }, paging: true, // Enable pagination pageLength: 25 // Set default number of rows per page (optional) diff --git a/app/Views/report_bds_filter.php b/app/Views/report_bds_filter.php index bc5db80b..d55ab379 100644 --- a/app/Views/report_bds_filter.php +++ b/app/Views/report_bds_filter.php @@ -169,8 +169,6 @@ $(document).ready(function() { - getClientAndBranchAndPolicy() - getURLParams() $('#client_id').select2(); $('#client_branch_id').select2(); $('#insurer_id').select2(); @@ -179,7 +177,9 @@ $('#client_policy_id').select2(); $('#user_id').select2(); - }) + getClientAndBranchAndPolicy(); + }); + function fetchEmpolyeeList(event) { event.preventDefault(); // Prevent default action @@ -223,21 +223,30 @@ return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&'); } + function getSafeParam(params, paramName) { + const val = params.get(paramName); + if (val === null || val === '' || val === 'null' || val === 'undefined' || val === undefined) { + return ''; + } + return val; + } + + function getURLParams() { const url = new URL(window.location.href); const params = new URLSearchParams(url.search); - const startDate = params.get('start_date') || 0; // Default to 0 if not found - const endDate = params.get('end_date') || 0; // Default to 0 if not found - const client_id = params.get('client_id') || 0; // Default to 0 if not found - const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found - const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found - const date_type = params.get('date_type') || 0; // Default to 0 if not found - const issuer = params.get('issuer') || 0; // Default to 0 if not found - const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found - const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found - const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found - const user_id = params.get('user_id') || 0; // Default to 0 if not found + const startDate = getSafeParam(params, 'start_date'); + const endDate = getSafeParam(params, 'end_date'); + const client_id = getSafeParam(params, 'client_id'); + const insurer_id = getSafeParam(params, 'insurer_id'); + const policy_type_id = getSafeParam(params, 'policy_type_id'); + const date_type = getSafeParam(params, 'date_type'); + const issuer = getSafeParam(params, 'issuer'); + const client_branch_id = getSafeParam(params, 'client_branch_id'); + const insurer_branch_id = getSafeParam(params, 'insurer_branch_id'); + const client_policy_id = getSafeParam(params, 'client_policy_id'); + const user_id = getSafeParam(params, 'user_id'); hideDateField(date_type) @@ -258,24 +267,38 @@ console.log('End Date:', endDate); if (startDate != 0 && endDate != 0) { - setTimeout(function() { - $('#start_date').val(startDate) - $('#end_date').val(endDate) - $('#client_id').val(client_id).select2() - $('#insurer_id').val(insurer_id).select2() - $('#user_id').val(user_id).select2() - $('#policy_type_id').val(policy_type_id).select2() - $('#date_type').val(date_type).trigger('change'); - $('#issuer').val(issuer) - setTimeout(function() { - $('#client_branch_id').val(client_branch_id).select2() - $('#insurer_branch_id').val(insurer_branch_id).select2() + // wait for dropdowns (Select2) to be loaded setTimeout(function() { - $('#client_policy_id').val(client_policy_id).select2(); - }, 1000); - }, 2000) - }, 1000) + // Step 1: Set top-level fields first + $('#startDate').val(startDate); + $('#endDate').val(endDate); + $('#client_id').val(client_id).trigger('change.select2'); + $('#insurer_id').val(insurer_id).trigger('change.select2'); + $('#user_id').val(user_id).trigger('change.select2'); + $('#policy_type_id').val(policy_type_id).trigger('change.select2'); + $('#date_type').val(date_type).trigger('change'); + $('#issuer').val(issuer); + // Step 2: Wait a bit to let change events happen + setTimeout(function() { + // populate branch dropdowns manually if data exists + if (client_id && branch_list[client_id]) { + appendBranch(branch_list[client_id]); + } + if (insurer_id && insurer_branch_list[insurer_id]) { + appendInsurerBranch(insurer_branch_list[insurer_id]); + } + + // Step 3: Set branch selections + $('#client_branch_id').val(client_branch_id).trigger('change.select2'); + $('#insurer_branch_id').val(insurer_branch_id).trigger('change.select2'); + + // Step 4: After branches, handle client policies + setTimeout(function() { + $('#client_policy_id').val(client_policy_id).trigger('change.select2'); + }, 500); + }, 500); + }, 500); } } @@ -370,6 +393,7 @@ insurer_branch_list = res.insurer_branch_data; appendClients(res.client_data); appendInsurer(res.insurer_data); + getURLParams(); } else { console.log('No data found'); } @@ -401,6 +425,7 @@ }); $('#client_id').append(option); + }); } @@ -469,7 +494,6 @@ function appendPolicies(data) { // console.log('appendPolicies', data); // console.log('appendPolicies', $('#client_policy_id')); - $('#client_policy_id').empty(); $('#client_policy_id').append($('
S.No 
S.No
Insurer Insurer
Branch 
Statement
Month 
Statement
No 
Invoice No Invoice Status Invoice Date Invoice Amount Realization
Amount 
Outstanding
Amount 
Insurer
Insurer
Branch
Statement
Month
Statement
No
Invoice No
Invoice Status
Invoice Date
Invoice Amount
Realization
Amount
Outstanding
Amount
@@ -62,6 +64,7 @@ table.dataTable thead th {
Advertisement Image Name
+
@@ -110,6 +113,40 @@ table.dataTable thead th { diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index 1762f32c..8075471d 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -487,12 +487,16 @@ table.dataTable tbody td { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/nhance_branch_list.php b/app/Views/nhance_branch_list.php index 8d0c1add..32c7c09c 100644 --- a/app/Views/nhance_branch_list.php +++ b/app/Views/nhance_branch_list.php @@ -124,11 +124,15 @@ ], language: { search: ` -
+
_INPUT_ - + +
`, - searchPlaceholder: "Search" + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/outstanding_report_list.php b/app/Views/outstanding_report_list.php index 496c9afa..bd45e251 100644 --- a/app/Views/outstanding_report_list.php +++ b/app/Views/outstanding_report_list.php @@ -226,12 +226,16 @@ ] }], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 25 // Set default number of rows per page (optional) diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index d91ef483..6f5485cb 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -519,12 +519,16 @@ table.dataTable thead th { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index ede897ce..37640c11 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -591,12 +591,16 @@ $(document).ready(function() { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/policy_type_list.php b/app/Views/policy_type_list.php index 990f06a5..2f6d6002 100755 --- a/app/Views/policy_type_list.php +++ b/app/Views/policy_type_list.php @@ -250,12 +250,16 @@ ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true , diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index 364a3fdd..2261d79c 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -456,12 +456,16 @@ $(document).ready(function() { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/report_bds_new.php b/app/Views/report_bds_new.php index ae9db7cf..ed9b8fe3 100644 --- a/app/Views/report_bds_new.php +++ b/app/Views/report_bds_new.php @@ -500,12 +500,16 @@ } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/report_bds_old.php b/app/Views/report_bds_old.php index 261dade0..536769b6 100644 --- a/app/Views/report_bds_old.php +++ b/app/Views/report_bds_old.php @@ -189,8 +189,16 @@ $(document).ready(function() { ], language: { - search: "_INPUT_", - searchPlaceholder: "Search..." + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/retail_endorsement_list.php b/app/Views/retail_endorsement_list.php index 44bbacbe..e605f723 100755 --- a/app/Views/retail_endorsement_list.php +++ b/app/Views/retail_endorsement_list.php @@ -391,12 +391,16 @@ }); }, language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // pagingType: 'full_numbers' diff --git a/app/Views/rto_master_list.php b/app/Views/rto_master_list.php index caafe3b3..d9ecfad6 100644 --- a/app/Views/rto_master_list.php +++ b/app/Views/rto_master_list.php @@ -147,11 +147,15 @@ ], language: { search: ` -
+
_INPUT_ - + +
`, - searchPlaceholder: "Search" + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/tat_report_band_wise_list.php b/app/Views/tat_report_band_wise_list.php index 39f0c068..e4ee2f19 100644 --- a/app/Views/tat_report_band_wise_list.php +++ b/app/Views/tat_report_band_wise_list.php @@ -134,12 +134,16 @@ } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/test_members_list.php b/app/Views/test_members_list.php index bc7e255b..946fe6ab 100644 --- a/app/Views/test_members_list.php +++ b/app/Views/test_members_list.php @@ -557,12 +557,16 @@ document.addEventListener("DOMContentLoaded", function () { className:"unmapEmployees" }], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 25 // Set default number of rows per page (optional) diff --git a/app/Views/thz_list.php b/app/Views/thz_list.php index e4bc218a..63c64862 100644 --- a/app/Views/thz_list.php +++ b/app/Views/thz_list.php @@ -356,12 +356,16 @@ table.dataTable tbody td { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, pageLength: 10, diff --git a/app/Views/ticket_feedback_list.php b/app/Views/ticket_feedback_list.php index c8d2f304..3902ca42 100644 --- a/app/Views/ticket_feedback_list.php +++ b/app/Views/ticket_feedback_list.php @@ -138,13 +138,17 @@ $(document).ready(function() { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" - }, + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' + }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) ordering: false, diff --git a/app/Views/ticket_history.php b/app/Views/ticket_history.php index 505fe971..54711dd2 100644 --- a/app/Views/ticket_history.php +++ b/app/Views/ticket_history.php @@ -60,13 +60,17 @@ if (ticketsTable.length) { // ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" - }, + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' + }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) ordering: false, diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index 2b542f78..bc5c065b 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -325,12 +325,16 @@ $(document).ready(function() { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/ticket_mail_template.php b/app/Views/ticket_mail_template.php index d816f2a3..a2cc86d5 100644 --- a/app/Views/ticket_mail_template.php +++ b/app/Views/ticket_mail_template.php @@ -265,12 +265,16 @@ } }], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/tpa_list.php b/app/Views/tpa_list.php index 19737cdc..412b9910 100755 --- a/app/Views/tpa_list.php +++ b/app/Views/tpa_list.php @@ -208,13 +208,17 @@ } ], language: { - search: ` -
+ search: ` +
_INPUT_ - + +
`, - searchPlaceholder: "Search" - }, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' + }, paging: true, }); diff --git a/app/Views/variance_report_list.php b/app/Views/variance_report_list.php index 279fd493..800334a1 100644 --- a/app/Views/variance_report_list.php +++ b/app/Views/variance_report_list.php @@ -268,13 +268,17 @@ } ] }], - language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + language: { + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 25 // Set default number of rows per page (optional) diff --git a/app/Views/vehicle_master_list.php b/app/Views/vehicle_master_list.php index 84059a5d..2e54f852 100644 --- a/app/Views/vehicle_master_list.php +++ b/app/Views/vehicle_master_list.php @@ -510,13 +510,17 @@ $(document).ready(function() { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" - }, + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' + }, paging: true, pageLength: 10, order: [[0, 'desc']] diff --git a/app/Views/vehicle_type_list.php b/app/Views/vehicle_type_list.php index 6692bf58..ce0181d5 100644 --- a/app/Views/vehicle_type_list.php +++ b/app/Views/vehicle_type_list.php @@ -856,13 +856,17 @@ paging: true, pageLength: 10, language: { - search: ` -
+ search: ` +
_INPUT_ - + +
`, - searchPlaceholder: "Search" - }, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' + }, initComplete: function () { $(".dt-buttons").prepend(`
diff --git a/app/Views/vehicle_type_master_list.php b/app/Views/vehicle_type_master_list.php index 7dd4e3a1..fd6d0801 100755 --- a/app/Views/vehicle_type_master_list.php +++ b/app/Views/vehicle_type_master_list.php @@ -124,12 +124,16 @@ ], language: { search: ` -
+
_INPUT_ - + +
`, - searchPlaceholder: "Search" - }, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' + }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) // ordering: false, diff --git a/app/Views/view_deposit.php b/app/Views/view_deposit.php index 606da89e..d382d21c 100755 --- a/app/Views/view_deposit.php +++ b/app/Views/view_deposit.php @@ -347,12 +347,16 @@ } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, ordering: false, paging: true From 1ccfaa782de42acb5d55278c39b3138950709ec0 Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Wed, 12 Nov 2025 12:25:36 +0530 Subject: [PATCH 21/30] FIX_"Negative" symbol remove --- app/Views/policy_transaction_endorsement_form.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 2c1bfae3..74b862a3 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -1432,7 +1432,9 @@ let bap = selectedOption.data('bap') || ''; let allocg = selectedOption.data('allocg') || ''; let endorsement_type = $('#action_type').val(); - let isDeletion = endorsement_type === "deletion"; + // let isDeletion = endorsement_type === "deletion"; // OLD + let isDeletion = false; // REF : VR,SVR and SVM remove "-" . + console.log("bap:", bap, "allocg:", allocg, "isDeletion:", isDeletion); From bdb678e59a92ed9f28575412ee5fbf0afbc57b5c Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 12 Nov 2025 12:26:54 +0530 Subject: [PATCH 22/30] FIX_HR_RELATED_ISSUES --- app/Controllers/ClientController.php | 530 ++++++++++++++++++++------- app/Views/hr_access_controll.php | 43 ++- 2 files changed, 417 insertions(+), 156 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index fb69bbcd..0bed75f5 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5661,7 +5661,7 @@ class ClientController extends AdminController // $employeeController = new EmployeeController(); // $employeeController->truncateFileData('633'); - // $res = $this->getHrAccessData(4005); dd($res); + // $res = $this->getHrAccessData(4075); dd($res); // ---------- TICKET SERVICE CONTROLLER -------------------------------------------------------------------------------- @@ -7025,177 +7025,434 @@ class ClientController extends AdminController return $combinedHrAccessData; } + // do not remove this commented items + // public function constructHrAccessData($data, $client_id , $pre_client_id) + // { + // // print_rr($data);die; + + // $preHrs = $data['pre_hr_data']; + // $postHrs = $data['post_hr_data']; + // $hrAccessTableData = $data['hr_access_table_data']; + // $merged = []; + + // // Merge based on mobile and email + // foreach ($postHrs as $post) { + // $found = false; + // foreach ($preHrs as $index => $pre) { + + // if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) { + + // $merged[] = [ + // 'pre_hr_id' => $pre['pre_hr_id'], + // 'post_hr_id' => $post['post_hr_id'], + // 'hr_name' => $post['hr_name'], + // 'hr_mobile' => $post['hr_mobile'], + // 'hr_mail' => $post['hr_mail'], + // 'pre_branch_id' => $pre['pre_branch_id'] ?? null, + // 'post_branch_id' => $post['post_branch_id'] ?? null, + // 'post_branch_name' => $post['post_branch_name'] ?? null + // ]; + // unset($preHrs[$index]); // remove matched pre_hr + // $found = true; + // break; + // } + // } + + // if (!$found) { + // $merged[] = [ + // 'pre_hr_id' => null, + // 'post_hr_id' => $post['post_hr_id'], + // 'hr_name' => $post['hr_name'], + // 'hr_mobile' => $post['hr_mobile'], + // 'hr_mail' => $post['hr_mail'], + // 'pre_branch_id' => $pre['pre_branch_id'] ?? null, + // 'post_branch_id' => $post['post_branch_id'] ?? null , + // 'post_branch_name' => $post['post_branch_name'] ?? null + // ]; + // } + // } + + // // Remaining preHrs (not matched) + // foreach ($preHrs as $pre) { + + // foreach ($merged as $value) { + // if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) { + // continue 2; // Skip adding this pre_hr as it's already matched + // } + // } + + // $merged[] = [ + // 'pre_hr_id' => $pre['pre_hr_id'], + // 'post_hr_id' => null, + // 'hr_name' => $pre['hr_name'], + // 'hr_mobile' => $pre['hr_mobile'], + // 'hr_mail' => $pre['hr_mail'], + // 'pre_branch_id' => $pre['pre_branch_id'] ?? null, + // 'post_branch_id' => $post['post_branch_id'] ?? null , + // 'post_branch_name' => $post['post_branch_name'] ?? null + // ]; + // } + + // // dd($merged); + + // $result = []; + + // if (empty($hrAccessTableData)) { + + // // No access data — fill result with hr data and other fields as null + // foreach ($merged as $hr) { + // $result[] = [ + // 'hr_access_table_pk' => null, + // 'post_client_id' => $client_id ?? null, + // 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + // 'post_hr_id' => $hr['post_hr_id'] ?? null, + // 'allowed_pre_modules' => [], + // 'allowed_post_modules' => [], + // 'allowed_pre_policies' => [], + // 'allowed_active_policies' => [], + // 'allowed_cd' => [], + // 'hr_name' => $hr['hr_name'] ?? null, + // 'hr_mobile' => $hr['hr_mobile'] ?? null, + // 'hr_mail' => $hr['hr_mail'] ?? null, + // 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + // 'post_branch_id' => $hr['post_branch_id'] ?? null , + // 'post_branch_name' => $hr['post_branch_name'] ?? null , + // 'pre_client_id' => $pre_client_id ?? null + // ]; + // } + // } else { + // // First create a map of HR data by post_hr_id for quick lookup + // $hrMap = []; + // foreach ($merged as $hr) { + // $hrMap[$hr['post_hr_id']] = $hr; + // } + + // // Process access data first + // foreach ($hrAccessTableData as $access) { + // $post_hr_id = $access['post_hr_id']; + + // // Check if this HR exists in our merged data + // if (isset($hrMap[$post_hr_id])) { + // $hr = $hrMap[$post_hr_id]; + // $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + + // // Parse allowed modules + // $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; + // $allowed_pre_modules = $allowed_modules['pre'] ?? []; + // $allowed_post_modules = $allowed_modules['post'] ?? []; + + // $result[$temp_arr_key] = [ + // 'hr_access_table_pk' => $access['id'] ?? null, + // 'post_client_id' => $access['post_client_id'] ?? null, + // 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + // 'post_hr_id' => $hr['post_hr_id'] ?? null, + // 'allowed_pre_modules' => $allowed_pre_modules, + // 'allowed_post_modules' => $allowed_post_modules, + // 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], + // 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [], + // 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], + // 'hr_name' => $hr['hr_name'], + // 'hr_mobile' => $hr['hr_mobile'], + // 'hr_mail' => $hr['hr_mail'], + // 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + // 'post_branch_id' => $hr['post_branch_id'] ?? null , + // 'post_branch_name' => $hr['post_branch_name'] ?? null , + // 'pre_client_id' => $pre_client_id ?? null + // ]; + + // // Remove from map so we know it's been processed + // unset($hrMap[$post_hr_id]); + // } + // } + + // // Now process any remaining HRs that didn't have access records + // foreach ($hrMap as $hr) { + // $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + + // $result[$temp_arr_key] = [ + // 'hr_access_table_pk' => null, + // 'post_client_id' => $client_id ?? null, + // 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + // 'post_hr_id' => $hr['post_hr_id'] ?? null, + // 'allowed_pre_modules' => [], + // 'allowed_post_modules' => [], + // 'allowed_pre_policies' => [], + // 'allowed_active_policies' => [], + // 'allowed_cd' => [], + // 'hr_name' => $hr['hr_name'] ?? null, + // 'hr_mobile' => $hr['hr_mobile'] ?? null, + // 'hr_mail' => $hr['hr_mail'] ?? null, + // 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + // 'post_branch_id' => $hr['post_branch_id'] ?? null , + // 'post_branch_name' => $hr['post_branch_name'] ?? null , + // 'pre_client_id' => $pre_client_id ?? null + // ]; + // } + // } + + + // $resultData['hr_access_data'] = array_values($result); + // $resultData['pre_policy_data'] = $data['pre_policy_data']; + // $resultData['post_policy_data'] = $data['post_policy_data']; + // $resultData['post_cd_data'] = $data['post_cd_data']; + + // return $resultData; + // } + public function constructHrAccessData($data, $client_id , $pre_client_id) - { - // print_rr($data);die; + { + try{ - $preHrs = $data['pre_hr_data']; - $postHrs = $data['post_hr_data']; - $hrAccessTableData = $data['hr_access_table_data']; - $merged = []; + $preHrs = $data['pre_hr_data']; + $postHrs = $data['post_hr_data']; + $hrAccessTableData = $data['hr_access_table_data']; + $merged = []; - // Merge based on mobile and email - foreach ($postHrs as $post) { - $found = false; - foreach ($preHrs as $index => $pre) { + // Merge based on mobile and email + foreach ($postHrs as $post) { + $found = false; + foreach ($preHrs as $index => $pre) { - if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) { + if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) { + $merged[] = [ + 'pre_hr_id' => $pre['pre_hr_id'], + 'post_hr_id' => $post['post_hr_id'], + 'hr_name' => $post['hr_name'], + 'hr_mobile' => $post['hr_mobile'], + 'hr_mail' => $post['hr_mail'], + 'pre_branch_id' => $pre['pre_branch_id'] ?? null, + 'post_branch_id' => $post['post_branch_id'] ?? null, + 'post_branch_name' => $post['post_branch_name'] ?? null + ]; + unset($preHrs[$index]); // remove matched pre_hr + $found = true; + break; + } + } + + if (!$found) { $merged[] = [ - 'pre_hr_id' => $pre['pre_hr_id'], + 'pre_hr_id' => null, 'post_hr_id' => $post['post_hr_id'], 'hr_name' => $post['hr_name'], 'hr_mobile' => $post['hr_mobile'], 'hr_mail' => $post['hr_mail'], 'pre_branch_id' => $pre['pre_branch_id'] ?? null, - 'post_branch_id' => $post['post_branch_id'] ?? null, - 'post_branch_name' => $post['post_branch_name'] ?? null + 'post_branch_id' => $post['post_branch_id'] ?? null , + 'post_branch_name' => $post['post_branch_name'] ?? null ]; - unset($preHrs[$index]); // remove matched pre_hr - $found = true; - break; } } - if (!$found) { + // Remaining preHrs (not matched) + foreach ($preHrs as $pre) { + + foreach ($merged as $value) { + if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) { + continue 2; // Skip adding this pre_hr as it's already matched + } + } + $merged[] = [ - 'pre_hr_id' => null, - 'post_hr_id' => $post['post_hr_id'], - 'hr_name' => $post['hr_name'], - 'hr_mobile' => $post['hr_mobile'], - 'hr_mail' => $post['hr_mail'], + 'pre_hr_id' => $pre['pre_hr_id'], + 'post_hr_id' => null, + 'hr_name' => $pre['hr_name'], + 'hr_mobile' => $pre['hr_mobile'], + 'hr_mail' => $pre['hr_mail'], 'pre_branch_id' => $pre['pre_branch_id'] ?? null, 'post_branch_id' => $post['post_branch_id'] ?? null , 'post_branch_name' => $post['post_branch_name'] ?? null ]; } - } - // Remaining preHrs (not matched) - foreach ($preHrs as $pre) { + $result = []; - foreach ($merged as $value) { - if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) { - continue 2; // Skip adding this pre_hr as it's already matched - } - } - - $merged[] = [ - 'pre_hr_id' => $pre['pre_hr_id'], - 'post_hr_id' => null, - 'hr_name' => $pre['hr_name'], - 'hr_mobile' => $pre['hr_mobile'], - 'hr_mail' => $pre['hr_mail'], - 'pre_branch_id' => $pre['pre_branch_id'] ?? null, - 'post_branch_id' => $post['post_branch_id'] ?? null , - 'post_branch_name' => $post['post_branch_name'] ?? null - ]; - } + if (empty($hrAccessTableData)) { - // dd($merged); - - $result = []; - - if (empty($hrAccessTableData)) { - - // No access data — fill result with hr data and other fields as null - foreach ($merged as $hr) { - $result[] = [ - 'hr_access_table_pk' => null, - 'post_client_id' => $client_id ?? null, - 'pre_hr_id' => $hr['pre_hr_id'] ?? null, - 'post_hr_id' => $hr['post_hr_id'] ?? null, - 'allowed_pre_modules' => [], - 'allowed_post_modules' => [], - 'allowed_pre_policies' => [], - 'allowed_active_policies' => [], - 'allowed_cd' => [], - 'hr_name' => $hr['hr_name'] ?? null, - 'hr_mobile' => $hr['hr_mobile'] ?? null, - 'hr_mail' => $hr['hr_mail'] ?? null, - 'pre_branch_id' => $hr['pre_branch_id'] ?? null, - 'post_branch_id' => $hr['post_branch_id'] ?? null , - 'post_branch_name' => $hr['post_branch_name'] ?? null , - 'pre_client_id' => $pre_client_id ?? null - ]; - } - } else { - // First create a map of HR data by post_hr_id for quick lookup - $hrMap = []; - foreach ($merged as $hr) { - $hrMap[$hr['post_hr_id']] = $hr; - } - - // Process access data first - foreach ($hrAccessTableData as $access) { - $post_hr_id = $access['post_hr_id']; - - // Check if this HR exists in our merged data - if (isset($hrMap[$post_hr_id])) { - $hr = $hrMap[$post_hr_id]; - $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; - - // Parse allowed modules - $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; - $allowed_pre_modules = $allowed_modules['pre'] ?? []; - $allowed_post_modules = $allowed_modules['post'] ?? []; - - $result[$temp_arr_key] = [ - 'hr_access_table_pk' => $access['id'] ?? null, - 'post_client_id' => $access['post_client_id'] ?? null, + // No access data — fill result with hr data and other fields as null + foreach ($merged as $hr) { + $result[] = [ + 'hr_access_table_pk' => null, + 'post_client_id' => $client_id ?? null, 'pre_hr_id' => $hr['pre_hr_id'] ?? null, 'post_hr_id' => $hr['post_hr_id'] ?? null, - 'allowed_pre_modules' => $allowed_pre_modules, - 'allowed_post_modules' => $allowed_post_modules, - 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], - 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [], - 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], - 'hr_name' => $hr['hr_name'], - 'hr_mobile' => $hr['hr_mobile'], - 'hr_mail' => $hr['hr_mail'], + 'allowed_pre_modules' => [], + 'allowed_post_modules' => [], + 'allowed_pre_policies' => [], + 'allowed_active_policies' => [], + 'allowed_cd' => [], + 'hr_name' => $hr['hr_name'] ?? null, + 'hr_mobile' => $hr['hr_mobile'] ?? null, + 'hr_mail' => $hr['hr_mail'] ?? null, 'pre_branch_id' => $hr['pre_branch_id'] ?? null, 'post_branch_id' => $hr['post_branch_id'] ?? null , 'post_branch_name' => $hr['post_branch_name'] ?? null , 'pre_client_id' => $pre_client_id ?? null ]; + } - // Remove from map so we know it's been processed - unset($hrMap[$post_hr_id]); + } else { + + // First create a map of HR data by post_hr_id for quick lookup + $hrMap = []; + foreach ($merged as $hr) { + if(!empty($hr['post_hr_id'])){ + $hrMap['post_hr_id_' . $hr['post_hr_id']] = $hr; + }else{ + $hrMap['pre_hr_id_' . $hr['pre_hr_id']] = $hr; + } + } + + // Process access data first + foreach ($hrAccessTableData as $access) { + + $post_hr_id = $access['post_hr_id']; + $pre_hr_id = $access['pre_hr_id']; + + if (empty($post_hr_id) && !empty($pre_hr_id)) { + $type_of_access_data = "PRE"; + } elseif (!empty($post_hr_id) && empty($pre_hr_id)) { + $type_of_access_data = "POST"; + } elseif (!empty($post_hr_id) && !empty($pre_hr_id)) { + $type_of_access_data = "POST&PRE"; + } else { + $type_of_access_data = "UNKNOWN"; + } + + // Check if this HR exists in our merged data + if (isset($hrMap['post_hr_id_' . $post_hr_id])) { + + $hr = $hrMap['post_hr_id_' . $post_hr_id]; + $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'] . $post_hr_id; + + // Parse allowed modules + $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; + $allowed_pre_modules = $allowed_modules['pre'] ?? []; + $allowed_post_modules = $allowed_modules['post'] ?? []; + + $result[$temp_arr_key] = [ + 'hr_access_table_pk' => $access['id'] ?? null, + 'post_client_id' => $access['post_client_id'] ?? null, + 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + 'post_hr_id' => $hr['post_hr_id'] ?? null, + 'allowed_pre_modules' => $allowed_pre_modules, + 'allowed_post_modules' => $allowed_post_modules, + 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], + 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [], + 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], + 'hr_name' => $hr['hr_name'], + 'hr_mobile' => $hr['hr_mobile'], + 'hr_mail' => $hr['hr_mail'], + 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + 'post_branch_id' => $hr['post_branch_id'] ?? null , + 'post_branch_name' => $hr['post_branch_name'] ?? null , + 'pre_client_id' => $pre_client_id ?? null, + 'type_of_access_data' => $type_of_access_data ?? null + ]; + + // Remove from map so we know it's been processed + unset($hrMap['post_hr_id_' . $post_hr_id]); + + }else if (isset($hrMap['pre_hr_id_' . $pre_hr_id])){ + + $hr = $hrMap['pre_hr_id_' . $pre_hr_id]; + $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'] . $post_hr_id; + + // Parse allowed modules + $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; + $allowed_pre_modules = $allowed_modules['pre'] ?? []; + $allowed_post_modules = $allowed_modules['post'] ?? []; + + $result[$temp_arr_key] = [ + 'hr_access_table_pk' => $access['id'] ?? null, + 'post_client_id' => $access['post_client_id'] ?? null, + 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + 'post_hr_id' => $hr['post_hr_id'] ?? null, + 'allowed_pre_modules' => $allowed_pre_modules, + 'allowed_post_modules' => $allowed_post_modules, + 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], + 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [], + 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], + 'hr_name' => $hr['hr_name'], + 'hr_mobile' => $hr['hr_mobile'], + 'hr_mail' => $hr['hr_mail'], + 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + 'post_branch_id' => $hr['post_branch_id'] ?? null , + 'post_branch_name' => $hr['post_branch_name'] ?? null , + 'pre_client_id' => $pre_client_id ?? null, + 'type_of_access_data' => $type_of_access_data ?? null + ]; + + // Remove from map so we know it's been processed + unset($hrMap['pre_hr_id_' . $pre_hr_id]); + + } + } + + // Now process any remaining HRs that didn't have access records + foreach ($hrMap as $hr) { + + $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + $post_hr_id = $hr['post_hr_id']; + $pre_hr_id = $hr['pre_hr_id']; + + if (empty($post_hr_id) && !empty($pre_hr_id)) { + $type_of_access_data = "PRE"; + } elseif (!empty($post_hr_id) && empty($pre_hr_id)) { + $type_of_access_data = "POST"; + } elseif (!empty($post_hr_id) && !empty($pre_hr_id)) { + $type_of_access_data = "POST&PRE"; + } else { + $type_of_access_data = "UNKNOWN"; + } + + $result[$temp_arr_key] = [ + 'hr_access_table_pk' => null, + 'post_client_id' => $client_id ?? null, + 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + 'post_hr_id' => $hr['post_hr_id'] ?? null, + 'allowed_pre_modules' => [], + 'allowed_post_modules' => [], + 'allowed_pre_policies' => [], + 'allowed_active_policies' => [], + 'allowed_cd' => [], + 'hr_name' => $hr['hr_name'] ?? null, + 'hr_mobile' => $hr['hr_mobile'] ?? null, + 'hr_mail' => $hr['hr_mail'] ?? null, + 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + 'post_branch_id' => $hr['post_branch_id'] ?? null , + 'post_branch_name' => $hr['post_branch_name'] ?? null , + 'pre_client_id' => $pre_client_id ?? null, + 'type_of_access_data' => $type_of_access_data ?? null + ]; } } - // Now process any remaining HRs that didn't have access records - foreach ($hrMap as $hr) { - $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + // dd($result); + $resultData['hr_access_data'] = array_values($result); + $resultData['pre_policy_data'] = $data['pre_policy_data']; + $resultData['post_policy_data'] = $data['post_policy_data']; + $resultData['post_cd_data'] = $data['post_cd_data']; - $result[$temp_arr_key] = [ - 'hr_access_table_pk' => null, - 'post_client_id' => $client_id ?? null, - 'pre_hr_id' => $hr['pre_hr_id'] ?? null, - 'post_hr_id' => $hr['post_hr_id'] ?? null, - 'allowed_pre_modules' => [], - 'allowed_post_modules' => [], - 'allowed_pre_policies' => [], - 'allowed_active_policies' => [], - 'allowed_cd' => [], - 'hr_name' => $hr['hr_name'] ?? null, - 'hr_mobile' => $hr['hr_mobile'] ?? null, - 'hr_mail' => $hr['hr_mail'] ?? null, - 'pre_branch_id' => $hr['pre_branch_id'] ?? null, - 'post_branch_id' => $hr['post_branch_id'] ?? null , - 'post_branch_name' => $hr['post_branch_name'] ?? null , - 'pre_client_id' => $pre_client_id ?? null - ]; - } + return $resultData; + + } catch (\Throwable $th) { + + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateInsurerStatement: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString()); + return []; + $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 ['status' => 'failed', 'code' => 500, 'message' => $th->getMessage(), 'error_data' => $errorData]; } - - - $resultData['hr_access_data'] = array_values($result); - $resultData['pre_policy_data'] = $data['pre_policy_data']; - $resultData['post_policy_data'] = $data['post_policy_data']; - $resultData['post_cd_data'] = $data['post_cd_data']; - - return $resultData; } public function saveHrAccessData() @@ -7846,7 +8103,4 @@ class ClientController extends AdminController - - - } diff --git a/app/Views/hr_access_controll.php b/app/Views/hr_access_controll.php index cbd2838e..f845b288 100644 --- a/app/Views/hr_access_controll.php +++ b/app/Views/hr_access_controll.php @@ -60,7 +60,6 @@ -
@@ -135,14 +134,18 @@ $policies) { $statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active'; $statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive'; - if ( - in_array($policies['branch_id'].'-'.$policies['policy_no'], $listed_pre) - && - $value['pre_branch_id'] != $policies['branch_id'] - ) { + // if ( + // in_array($policies['branch_id'].'-'.$policies['policy_no'], $listed_pre) + // && + // $value['pre_branch_id'] != $policies['branch_id'] + // ) { + // continue; + // } else { + // $listed_pre[] = $policies['branch_id'].'-'.$policies['policy_no']; + // } + + if($value['pre_branch_id'] !== $policies['branch_id']){ continue; - } else { - $listed_pre[] = $policies['branch_id'].'-'.$policies['policy_no']; } ?>
@@ -196,17 +199,21 @@ $policies) { $statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active'; $statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive'; - if( - in_array($policies['branch_id'].'-'.$policies['policy_no'] , $listed_post) - && - $value['post_branch_id'] != $policies['branch_id'] - ) - { + // if( + // in_array($policies['branch_id'].'-'.$policies['policy_no'] , $listed_post) + // && + // $value['post_branch_id'] != $policies['branch_id'] + // ) + // { + // continue; + // } + // else + // { + // $listed_post[] = $policies['branch_id'].'-'.$policies['policy_no']; + // } + + if($value['post_branch_id'] !== $policies['branch_id']){ continue; - } - else - { - $listed_post[] = $policies['branch_id'].'-'.$policies['policy_no']; } ?> From 9e1713446130d3d9f05a41189f5cbf3cd77fed3e Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 12 Nov 2025 13:09:33 +0530 Subject: [PATCH 23/30] FIX_HR --- app/Views/client_branch.php | 1 + app/Views/client_onboarding.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 178439fa..01ff9597 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -436,6 +436,7 @@ $("#branch_form").submit(function(event) { toastr.error(res.message, 'Error'); }else{ toastr.success(res.message, 'Success'); + newBranchSavedPeaseCallTheHrAccessFormApi = true; } // var message = (branch_PrimaryKey === '') ? // 'Client Branch Created successfully' : diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index 3dc798d6..3a195fe7 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -456,6 +456,7 @@