From 95b801018db88fded4e82f1283f7947719253e19 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 7 Jul 2025 22:36:30 +0530 Subject: [PATCH] CHANGE_MPIN_API_CLAIMS_RACK_RATE : RV --- app/Config/Routes.php | 2 + .../RestAuthenticationController.php | 298 +++++++++++++++--- app/Models/EmployeeModel.php | 2 + app/Views/policy_grid.php | 23 +- app/Views/ticket_form_handler.php | 248 +++++++++------ 5 files changed, 415 insertions(+), 158 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index fe5de65b..457388ff 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -543,6 +543,8 @@ $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEm $routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification"); $routes->post("sendEmail", "EmployeeRestController::send_email"); $routes->get("getPolicyLevelEmployeeSummaryData", "EmployeeRestController::getPolicyLevelEmployeeSummaryData"); +$routes->get("cdTransactionData", "EmployeeRestController::cdTransactionData"); +$routes->match( ['get', 'post'], 'claimsSearch','EmployeeRestController::claimsSearch'); $routes->get("getBackToEnrolledDetails", "EmployeeRestController::getBackToEnrolledDetails"); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 64eca662..e31ecb2a 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -340,9 +340,31 @@ class RestAuthenticationController extends AdminController }else{ if (isset($mobile_number)) { - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); + // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); + $employeeData = $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']) + ->where('employees.emp_status !=', 'truncated') + ->first(); } else { - $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); + // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); + $employeeData = $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']) + ->where('otp', $otp) + ->first(); } } @@ -364,7 +386,7 @@ class RestAuthenticationController extends AdminController $result = JWTToken::encode($employeeData); if(isset($this->request->getJSON()->otp)){ - $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->set(['otp'=>null])->update(); + $this->employeeModel->where('id', $employeeData['id'])->where('otp', $otp)->where('relationship', 'self')->set(['otp'=>null])->update(); } return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); @@ -602,9 +624,31 @@ class RestAuthenticationController extends AdminController $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null; if (isset($mobile_number)) { - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); + // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); + $employeeData = $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']) + ->orderBy('id', 'desc') + ->first(); } else { - $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first(); + // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first(); + $employeeData = $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']) + ->orderBy('id', 'desc') + ->first(); } $mpin = $this->request->getJSON()->mpin; @@ -650,14 +694,43 @@ class RestAuthenticationController extends AdminController $old_mpin = $this->request->getJSON()->old_mpin; $mpin = $this->request->getJSON()->new_mpin; - if (isset($mobile_number)) - { - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first(); - }else{ - $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first(); + // if (isset($mobile_number)) + // { + // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first(); + // }else{ + // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first(); + // } + + if (isset($mobile_number)) { + // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first(); + $employeeData = $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']) + ->where('employees.mpin', $old_mpin) + ->orderBy('id', 'desc') + ->first(); + } else { + // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first(); + $employeeData = $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']) + ->where('employees.mpin', $old_mpin) + ->orderBy('id', 'desc') + ->first(); } - if ($employeeData) { $id= $employeeData["id"]; @@ -681,45 +754,142 @@ class RestAuthenticationController extends AdminController } } + // public function verifyMpin() + // { + // try { + + // $mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null; + // $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null; + // $mpin = $this->request->getJSON()->mpin; + // if (isset($mobile_number)) + // { + // // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); + // $employeeData = $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']) + // ->get(); + // }else{ + // // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first(); + // $employeeData = $this->employeeModel + // ->select('employees.*') + // ->join('employee_polices', 'employees.id = employee_polices.employee_id') + // ->where('employees.email_corporate', $email_id) + // ->where('employee_polices.is_active', 1) + // ->whereIn('employee_polices.status', ['active']) + // ->where('employees.is_active', 1) + // ->whereIn('employees.emp_status', ['active']) + // ->where("employees.relationship", "Self") // RAW SQL condition + // ->first(); + + // } + // if ($employeeData && $mpin == $employeeData["mpin"]) { + + // $auth = HttpRequestHelper::getRequestInfo(); + // if ($auth) { + // $data = [ + // 'user_id' => $employeeData['id'], + // 'user_type' => 'employee', + // 'ip' => $auth['ip'], + // 'platform' => $auth['platform'], + // 'broswer' => $auth['browser'], + // ]; + + // $authdata= $this->authHistoryModel->insert($data); + + // } + + // $result = JWTToken::encode($employeeData); + // // $result = $employeeData; + // return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + // } else { + // return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200); + // } + // } catch (\Exception $e) { + // return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500); + // } + // } + public function verifyMpin() { try { + $requestData = $this->request->getJSON(true); - $mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null; - $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null; - $mpin = $this->request->getJSON()->mpin; - if (isset($mobile_number)) - { - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); - }else{ - $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first(); + $mobile_number = $requestData['mobile_number'] ?? null; + $email_id = $requestData['email_id'] ?? null; + $mpin = $requestData['mpin'] ?? null; + // print_r($mpin); + + if (!$mpin) { + return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'MPIN is required'], 400); } - if ($employeeData && $mpin == $employeeData["mpin"]) { - $auth = HttpRequestHelper::getRequestInfo(); + if ($mobile_number) { + $employeeData = $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']) + ->first(); + } elseif ($email_id) { + $employeeData = $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']) + ->first(); + } else { + return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Mobile number or Email ID is required'], 400); + } + + // print_r($employeeData); die; + + if ($employeeData && isset($employeeData['mpin']) && $mpin === $employeeData['mpin']) { + + $auth = HttpRequestHelper::getRequestInfo(); if ($auth) { - $data = [ - 'user_id' => $employeeData['id'], - 'user_type' => 'employee', - 'ip' => $auth['ip'], - 'platform' => $auth['platform'], - 'broswer' => $auth['browser'], - ]; - - $authdata= $this->authHistoryModel->insert($data); - + $this->authHistoryModel->insert([ + 'user_id' => $employeeData['id'], + 'user_type' => 'employee', + 'ip' => $auth['ip'], + 'platform' => $auth['platform'], + 'broswer' => $auth['browser'], // Note: typo in 'broswer' retained if it's your actual DB field + ]); } + $token = JWTToken::encode($employeeData); - - $result = JWTToken::encode($employeeData); - // $result = $employeeData; - return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + return $this->respond([ + 'status' => 'success', + 'code' => 200, + 'data' => $token + ], 200); } else { - return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200); + return $this->respond([ + 'status' => 'failed', + 'code' => 404, + 'data' => 'Invalid MPIN' + ], 200); } } catch (\Exception $e) { - return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500); + return $this->respond([ + 'status' => 'failed', + 'code' => 500, + 'data' => $e->getMessage() + ], 500); } } @@ -732,13 +902,33 @@ class RestAuthenticationController extends AdminController if (isset($mobile_number)) { - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); + // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); + $employeeData = $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']) + ->orderBy('id', 'desc') + ->first(); }else{ - $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first(); + // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first(); + $employeeData = $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']) + ->orderBy('id', 'desc') + ->first(); } - - if ($employeeData && $employeeData["mpin"] != null) { @@ -776,17 +966,31 @@ class RestAuthenticationController extends AdminController if ($mobile_number) { log_message('info', 'Looking up employee by mobile number: ' . $mobile_number); $employeeData = $this->employeeModel - ->where('mobile', $mobile_number) - ->where('relationship', 'self') - ->first(); + ->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) + ->where('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->where('employees.emp_status', ['active']) + ->first(); } else { log_message('info', 'Looking up employee by email: ' . $email_id); $employeeData = $this->employeeModel - ->where('email_corporate', $email_id) - ->where('relationship', 'self') - ->first(); + ->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) + ->where('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->where('employees.emp_status', ['active']) + ->first(); } + log_message('info', '$employeeData : ' . json_encode($employeeData)); + // Step 3: Found employee if (!empty($employeeData)) { log_message('info', 'Employee found: ID = ' . $employeeData['id']); diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index bb62234e..1bc55f06 100755 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -271,6 +271,8 @@ class EmployeeModel extends Model ->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left') ->where('employees.is_active', 1) ->where('employee_polices.is_active', 1) + ->where('employees.emp_status', "active") + ->where('employee_polices.status', "active") ->where('employees.emp_code', $emp_code); if(!empty($client_id)){ diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index dc0bb146..6626d85e 100755 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -92,7 +92,6 @@
- @@ -144,7 +143,7 @@
- + Rename
@@ -191,10 +190,9 @@ $(document).on('click', '.close', function() { var rarc_rate_json_array = []; $(document).on('submit', 'form[id^="GridForm_"]', function(event) { - console.log('submitted function called') - event.preventDefault(); // Prevent the default form submission + console.log('submitted function called') var form = $(this); console.log('form', form) @@ -830,12 +828,12 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
- +
@@ -1424,16 +1422,16 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false) html = `
- +
- +
- +
@@ -1450,7 +1448,7 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false) html = `
- +
@@ -1484,7 +1482,7 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
- +
@@ -3358,7 +3356,6 @@ function appendNewTab(tabNameData = null, data = null) newTabPane.innerHTML = `
- @@ -3409,7 +3406,7 @@ function appendNewTab(tabNameData = null, data = null)
- + Delete Rename
diff --git a/app/Views/ticket_form_handler.php b/app/Views/ticket_form_handler.php index 2b3b700c..c454791f 100644 --- a/app/Views/ticket_form_handler.php +++ b/app/Views/ticket_form_handler.php @@ -43,18 +43,16 @@ -