diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 7ab5ce5..becdca8 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -115,6 +115,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { $routes->post('policy/updatePolicy', 'PolicyController::updatePolicy'); $routes->get('policy/downloadPolicyFile', 'PolicyController::downloadPolicyFile'); $routes->post('policy/uploadPolicyFile', 'PolicyController::uploadPolicyFile'); + $routes->get("policy/searchThePolicies", "PolicyController::searchThePolicies"); //claims $routes->get('claim/ClaimList', 'ClaimController::ClaimList'); @@ -152,6 +153,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { }); + // $routes->get("policy/searchThePolicies", "PolicyController::searchThePolicies"); // $routes->get("dashboard/businessDashboard", "DashboardController::businessDashboard"); // $routes->get("dashboard/partnerDashboard", "DashboardController::partnerDashboard"); // $routes->get("dashboard/productivityDashboard", "DashboardController::productivityDashboard"); diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 842a5eb..07eceac 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -935,7 +935,7 @@ class DashboardController extends ResourceController $builder->where('pa.manager_id',$manager_id); - $builder->where('pp.id', null); + $builder->where('pp.id IS NULL'); $builder->orderBy('pa.name'); if ($raw === true) { return $builder->getCompiledSelect(); diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index a2c168f..5393b77 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -767,6 +767,46 @@ class PolicyController extends ResourceController } + public function searchThePolicies() { + + try{ + + $policy_number = $this->request->getGet('policy_number'); + $vehicle_no = $this->request->getGet('vehicle_number'); + if ($policy_number == '' && $vehicle_no == '') { + return $this->respond([ + 'status' => 'failed', + 'code' => 200, + 'data' => 'Value Required' + ], 200); + } + + $builder = $this->PolicyModel->select('partner_policy.*, v.vehicle_no'); + $builder->join('vehicle v', 'partner_policy.vehicle_id = v.id', 'left'); + + if ($policy_number) { + $builder->like('partner_policy.policy_number', $policy_number); + } elseif ($vehicle_no) { + $builder->like('v.vehicle_no', $vehicle_no); + } else { + $builder->groupStart() + ->like('partner_policy.policy_number', $policy_number) + ->orLike('v.vehicle_no', $vehicle_no) + ->groupEnd(); + } + $result = $builder->get()->getResultArray(); + if (!$result) { + return $this->respond(['status' => 'failed', 'code' => 200, 'data' => 'No Data Found'], 200); + } + + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500); + } +} + +