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() {