From d43e2ca101b31f64440cfb09ff9cf8055ee945a4 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Mon, 18 Mar 2024 19:45:05 +0530 Subject: [PATCH 1/3] GWM --- app/Config/Routes.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2c879a72..74688631 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -212,11 +212,12 @@ $routes->get("/getEmployeeProfile", "EmployeeRestController::getEmployeeProfile/ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfile"); -$routes->post("/employeeUpload", "EmployeeRestController::employeeUpload"); -$routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); + + $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ + $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); $routes->get("relationshipList", "EmployeeRestController::relationshipList"); $routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); $routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence"); From 62eec1f44c3caf44bae0c82425a45d4f5758b501 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Mon, 18 Mar 2024 20:09:46 +0530 Subject: [PATCH 2/3] GWM:CHANGE-IN-REST-API --- app/Config/Routes.php | 1 + app/Controllers/EmployeeRestController.php | 24 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 74688631..45cf2568 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -227,6 +227,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->post("createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount"); $routes->get("deleteDependence", "EmployeeRestController::deleteDependence"); $routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId"); + $routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy"); }); $routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 0f9e82f1..44a17c02 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -52,7 +52,7 @@ class EmployeeRestController extends AdminController $this->policesModel = new PolicesModel(); $this->relationshipModel = new RelationshipModel(); $this->fileModel= new FileModel(); - $this->clientPolicyModel= new ClientPolicyModel(); + $this->clientPolicyModel = new ClientPolicyModel(); } @@ -245,6 +245,28 @@ class EmployeeRestController extends AdminController } + public function getClientPolicy() + { + try { + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id,, policies.id as policy_id, policies.name as policy_name') + ->join('policies', 'client_policy.policy_id = policies.id', 'left') + ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->findAll(); + + // You probably meant to check $result, not $data + if ($ClientPolicyData) { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $ClientPolicyData], 200); + } else { + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); + } + + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } + + } + public function getEmployeePolicy() { From f99c0ca5e2a14f25594990780f21a74077ecc953 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Tue, 19 Mar 2024 11:39:08 +0530 Subject: [PATCH 3/3] CHANGES-in-restApi:GWM --- app/Config/Routes.php | 2 +- app/Controllers/EmployeeRestController.php | 35 +++++++++---------- .../RestAuthenticationController.php | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 45cf2568..cce60574 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -213,7 +213,7 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi - +$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy"); $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 44a17c02..139d39cd 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -211,29 +211,28 @@ class EmployeeRestController extends AdminController public function getEmployeeAndDependenceByClientId() { try { - $empData = $this->employeeModel - ->where('client_id', $this->request->getGet('client_id')) - ->where('relationship', 'self') - ->orderBy('id') - ->findAll(); + + $empData = $this->employeeModel->where('client_id', $this->request->getGet('client_id')) + ->where('relationship !=', null) + ->orderBy('emp_code')->orderBy('id')->findAll(); - $result = []; + // $result = []; - foreach ($empData as $employee) { - $employeeDependence = $this->employeeModel - ->where('emp_code', $employee['emp_code']) - ->where('relationship !=', 'self') - ->findAll(); + // foreach ($empData as $employee) { + // $employeeDependence = $this->employeeModel + // ->where('emp_code', $employee['emp_code']) + // ->where('relationship !=', 'self') + // ->findAll(); - // Use object notation to access properties and set 'dependence' - $employee['dependence'] = $employeeDependence ?: []; + // // Use object notation to access properties and set 'dependence' + // $employee['dependence'] = $employeeDependence ?: []; - $result[] = $employee; - } + // $result[] = $employee; + // } // You probably meant to check $result, not $data - if ($result) { - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); + if ($empData) { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200); } else { return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); } @@ -248,7 +247,7 @@ class EmployeeRestController extends AdminController public function getClientPolicy() { try { - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id,, policies.id as policy_id, policies.name as policy_name') + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name') ->join('policies', 'client_policy.policy_id = policies.id', 'left') ->where('client_policy.client_id', $this->request->getGet('client_id') ) ->findAll(); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 721e71a9..d3a3c111 100644 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -176,7 +176,7 @@ class RestAuthenticationController extends AdminController ->where('level_contacts.mobile', $mobile_number ) ->find(); - $result = JWTToken::encode($hrData); + $result = JWTToken::encode($hrData['0']); return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); } else { return $this->respond(['status' => 'failed','code' => 404,'data' => "No data"],404);