diff --git a/app/Config/Routes.php b/app/Config/Routes.php index fd1f09ca..5b334d55 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -650,6 +650,7 @@ $routes->group("employeeRest", ["filter" => ["authJWT"]], function ($routes) { $routes->post('initiateClaim',"EmployeeRestController::initiateClaim"); $routes->get('get_ticket_type',"EmployeeRestController::get_ticket_type"); $routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data"); + $routes->get('getClaimTypeMaster',"EmployeeRestController::getClaimTypeMaster"); // add retail policy $routes->post("addEmpRetailPolicy", "EmployeeRestController::addEmpRetailPolicy"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index bbade156..c57c69ad 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -57,6 +57,7 @@ use Illuminate\Http\Request; use App\Controllers\EmployeeServiceController; use App\Models\ClaimFilesModel; +use App\Models\PolicyTransactionModel; use App\Models\TicketMailTemplateModel; use App\Models\TpaApiSeviceModel; use Composer\Pcre\Preg; @@ -2584,6 +2585,8 @@ class EmployeeRestController extends AdminController $data['claims_data'] = $this->ticketMaster->getTicketDataByTicketID($ticket_id); $data['ticket_data'] = $ticketController->getMoreInfo($requestFrom = 'rest', $ticket_id); + $required_docs = $this->ticketMaster->select('required_docs')->where('id', $ticket_id)->first(); + $data['required_docs'] = json_decode($required_docs['required_docs'] ?? '{}', true) ?? []; // $ticketData = $data['ticket_data']; // $ticketHistory = $data['ticket_history']; // print_r($ticketHistory); die; @@ -3526,11 +3529,14 @@ class EmployeeRestController extends AdminController $received_data = $this->request->getPost(); $this->myLogger->logme('error', 'API claim initiate Recevied Params :' . json_encode($received_data ?? [])); - $get_file_data = $this->request->getFiles('claim_docs'); + $get_file_data = $this->request->getFiles('claim_docs') ?? null; $get_docs_name = $this->request->getPost('claim_doc_names') ?? []; - $policy_type_id = $this->request->getPost('policy_type_id') ?? null; - + $policy_transaction_id = $this->request->getPost('policy_transaction_id') ?? null; + if(!empty($policy_transaction_id)){ + $response = $this->retailClaimInitiate($received_data); + return $this->respond($response, 200); + } if (is_string($get_docs_name)) { $decoded = json_decode($get_docs_name, true); @@ -3685,6 +3691,62 @@ class EmployeeRestController extends AdminController } } + public function retailClaimInitiate($data) + { + if(isset($data['policy_transaction_id'])){ + + $policy_transaction_model = new PolicyTransactionModel(); + + $policy = $policy_transaction_model + ->select('policy_transaction.*, clients.client_name, clients.phone as client_mobile, clients.email as client_email') + ->join('clients', 'policy_transaction.client_id = clients.id') + ->where('policy_transaction.is_active',1) + ->where('clients.is_active',1) + ->where('policy_transaction.id', $data['policy_transaction_id']) + ->first(); + + if(!empty($policy)){ + + $claimData = [ + 'ticket_type_id' => $data['policy_type_id'], + 'claim_status_id' => 62, + 'policy_no' => $policy['policy_no'], + 'client_policy_id' => $policy['client_policy_id'], + 'insurer_id' => $policy['insurer_id'], + 'client_id' => $policy['client_id'] ?? null, + 'agent_id' => $policy['agent_id'] ?? null, + 'manager_id' => $policy['manager_id'] ?? null, + 'vehicle_id' => $policy['vehicle_id'] ?? null, + 'insured_name' => $policy['client_name'] ?? null, + 'emp_name' => $policy['client_name'] ?? null, + 'emp_mobile' => $policy['client_mobile'] ?? null, + 'emp_mail' => $policy['client_email'] ?? null, + 'emp_personal_mail'=> $policy['client_email'] ?? null, + 'claim_type' => $data['claim_type'], + 'claim_description'=> $data['claim_description'], + 'created_by' => $policy['client_id'] ?? null, + ]; + + $ticket_id = $this->ticketMaster->insert($claimData); + + if($ticket_id){ + $message = 'Claim Initiated Successfully'; + return ['status' => true, 'code' => 200, 'data' => $ticket_id, 'message' => $message]; + }else{ + $message = 'Claim Initiation failed'; + return ['status' => false, 'code' => 404, 'message' => $message]; + } + }else{ + $message = 'Claim Initiation failed. Policy data not found'; + return ['status' => false, 'code' => 404, 'message' => $message]; + } + }else{ + $message = 'Claim Initiation failed'; + return ['status' => false, 'code' => 404, 'message' => $message]; + + } + } + public function handleCliamFiles($data, $ticket_id, $ticket_message_id = null) { if (!empty($data) && !empty($ticket_id)) { @@ -4901,4 +4963,16 @@ class EmployeeRestController extends AdminController ], 200); } + public function getClaimTypeMaster() + { + $data = db_connect()->table('partner_claim_type_master')->select('id,claim_type')->where('is_active',1)->get()->getResultArray(); + + if (!$data) { + return $this->failNotFound('No data found'); + } + + return $this->respond(['status' => 200,'message' => 'success','data' => $data]); + } + + } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index a0189088..0236b837 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -89,6 +89,8 @@ class TicketMasterModel extends Model 'hospital_city', 'hospital_pin_code', 'hospital_phone_no', + 'claim_description', + 'required_docs', ];