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);