diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 11a9ebc9..67b28f68 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2501,11 +2501,12 @@ class EmployeeRestController extends AdminController $client_id = isset($search_data['client_id']) ? (int) $search_data['client_id'] : 0; unset($search_data['client_id']); unset($search_data['client_branch_id']); + $policy_number = isset($search_data['policy_no']) ? $search_data['policy_no'] : null; $from_date = isset($search_data['from_date']) ? $search_data['from_date'] : null; $to_date = isset($search_data['to_date']) ? $search_data['to_date'] : null; $claim_status_id = isset($search_data['claim_status_id']) ? $search_data['claim_status_id'] : null; - unset($search_data['from_date'], $search_data['to_date'], $search_data['claim_status_id']); + unset($search_data['from_date'], $search_data['to_date'], $search_data['claim_status_id'], $search_data['policy_no']); $where = []; @@ -2625,6 +2626,10 @@ class EmployeeRestController extends AdminController $builder->whereIn('claim_status_id', $claim_status_ids); } + if (!empty($policy_number)) { + $builder->where('cp.policy_no', $policy_number); + } + $builder->orderBy('tm.id', 'DESC'); $data = $builder->get()->getResultArray(); @@ -5500,12 +5505,17 @@ class EmployeeRestController extends AdminController return $this->respond(['status' => false, 'code' => 404, 'message' => 'No file found', 'data' => []], 200); } - $policyTransactionModel = new PolicyTransactionModel(); - $policy_transaction_data = $policyTransactionModel - ->where('is_active', 1) - ->where('policy_no', $client_policy_data['policy_no']) - ->where('action_type', $cd_data['event_name']) - ->findAll(); + $policyTransactionModel = new PolicyTransactionModel(); + $builder = $policyTransactionModel + ->where('is_active', 1) + ->where('policy_no', $client_policy_data['policy_no']) + ->where('action_type', $cd_data['event_name']); + + if (!empty($cd_data['endorsement_no']) && $cd_data['event_name'] != 'inception') { + $builder->where('endorsement_no', $cd_data['endorsement_no']); + } + + $policy_transaction_data = $builder->findAll(); if(empty($policy_transaction_data)){ $this->myLogger->logme('error', 'getPolicyAndEndorsementFiles: No Policy Transaction data found for policy_no=' . $client_policy_data['policy_no']);