From 81d1fb8246a568d129cb3f246c23995958fc0a16 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 11 Feb 2025 17:33:10 +0530 Subject: [PATCH] FIX_CLAIMS_MODULE : RV --- app/Controllers/ClientController.php | 127 ++++++++++++++------------- app/Controllers/TicketController.php | 6 +- app/Views/ticket_form_gmc.php | 4 +- app/Views/ticket_form_gpa.php | 14 ++- 4 files changed, 83 insertions(+), 68 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index d7a06cf5..a45cb7b9 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4327,44 +4327,7 @@ class ClientController extends AdminController // ----------------------------------------------------------------------------------------------------- - public function updateRenewalData() - { - $db = db_connect(); - $renewalData = $db->table('old_renewal_data_copy') - ->where('client_id IS NOT NULL') - ->where('is_inserted != 1') - ->get() - ->getResultArray(); - - $successData = []; - foreach ($renewalData as $key => $value) { - // Get branch_id properly - $branch = $this->clientBranchModel->where('client_id', $value['client_id'] ?? 0)->first(); - $value['branch_id'] = $branch['branch_id'] ?? null; - - // Fix vehicle_id key (previously "vehicel_id") - $value['vehicle_id'] = null; - if ($value['policy_type_id'] == 8 && !empty($value['policy_type_id'])) { - $value['vehicle_id'] = $this->prepareVehicleData($value); - } - - // Process client policy, policy transaction, and co-share details - $value['client_policy_id'] = $this->prepareClientPolicy($value); - $value['pt_id'] = $this->preparePolicyData($value); - $value['pt_co_id'] = $this->preparePtCoShareDetails($value); - - // Update is_inserted field in DB - $db->table('old_renewal_data_copy') - ->where('id', $value['id']) - ->set(['is_inserted' => 1]) - ->update(); - - $successData[] = ['id' => $value['id'], 'client' => $value['insured']]; - } - - kint::dump($successData); - } - + // private function preparePolicyData($renewalData) // { // $data = [ @@ -4388,11 +4351,11 @@ class ClientController extends AdminController // 'ct_type' => 1, // 'cd_ac_pk' => $renewalData['cd_ac_pk'] ?? null, // ]; - + // $policyTransactionModel = new PolicyTransactionModel(); // return $policyTransactionModel->insert($data); // } - + // private function prepareVehicleData($renewalData) // { // $vehicleData = [ @@ -4400,11 +4363,11 @@ class ClientController extends AdminController // 'owner' => $renewalData['client_id'], // 'branch_id' => ($renewalData['client_type_id'] == 1) ? $renewalData['branch_id'] : null, // ]; - + // $vehicleModel = new VehicleModel(); // return $vehicleModel->insert($vehicleData); // } - + // private function preparePtCoShareDetails($renewalData) // { // $ptCoShareDetails = [ @@ -4418,11 +4381,11 @@ class ClientController extends AdminController // 'tep_amt' => 0.00, // 'follower_policy_no' => $renewalData['policy_no'], // ]; - + // $ptCoShareDetailsModel = new PTCOShareDetailsModel(); // return $ptCoShareDetailsModel->insert($ptCoShareDetails); // } - + // private function prepareClientPolicy($renewalData) // { // $clientPolicy = [ @@ -4438,27 +4401,67 @@ class ClientController extends AdminController // 'gst' => 18.00, // 'cd_ac_pk' => $renewalData['cd_ac_pk'], // ]; - + // $clientPolicyModel = new ClientPolicyModel(); // return $clientPolicyModel->insert($clientPolicy); // } + public function updateRenewalData() + { + $db = db_connect(); + $renewalData = $db->table('old_renewal_data_copy') + ->where('client_id IS NOT NULL') + ->where('is_inserted != 1') + ->get() + ->getResultArray(); + // dd($renewalData); + + $successData = []; + foreach ($renewalData as $key => $value) { + // Get branch_id properly + $branch = $this->clientBranchModel->where('client_id', $value['client_id'] ?? 0)->first(); + // kint::dump($branch); + $value['branch_id'] = $branch['id'] ?? null; + + // Fix vehicle_id key (previously "vehicel_id") + $value['vehicle_id'] = null; + if ($value['policy_type_id'] == 8 && !empty($value['policy_type_id'])) { + $value['vehicle_id'] = $this->prepareVehicleData($value); + } + + // Process client policy, policy transaction, and co-share details + $value['client_policy_id'] = $this->prepareClientPolicy($value); + $value['pt_id'] = $this->preparePolicyData($value); + $value['pt_co_id'] = $this->preparePtCoShareDetails($value); + + // Update is_inserted field in DB + $db->table('old_renewal_data_copy') + ->where('id', $value['id']) + ->set(['is_inserted' => 1]) + ->update(); + + $successData[] = ['id' => $value['id'], 'client' => $value['insured']]; + } + + kint::dump($successData); + } + private function preparePolicyData($renewalData) - { + { $data = [ - 'issuer' => $renewalData['issuer_type_id'], - 'client_id' => $renewalData['client_id'], + 'issuer' => $renewalData['issuer_type_id'] ?? null, + 'client_id' => $renewalData['client_id'] ?? null, 'client_branch_id' => $renewalData['branch_id'] ?? 0, - 'vehicle_id' => $renewalData['vehicel_id'], - 'insurer_id' => $renewalData['insurer_id'], + 'vehicle_id' => $renewalData['vehicel_id'] ?? null, + 'insurer_id' => $renewalData['insurer_id'] ?? null, 'insurer_branch_id' => $renewalData['insurer_branch_id'], 'tpa_id' => null, 'tpa_branch_id' => null, - 'policy_type_id' => $renewalData['policy_type_id'], + 'policy_type_id' => $renewalData['policy_type_id'] ?? null, 'client_policy_id' => $renewalData['client_policy_id'] ?? null, 'issue_type' => 1, 'source_client_policy_id' => null, - 'policy_no' => $renewalData['policy_no'], + 'policy_no' => $renewalData['policy_no'] ?? null, 'cd_ac_no' => null, 'policy_issue_date' => $renewalData['date_date_of_issue'], 'policy_start_date' => $renewalData['date_policy_start_date'], @@ -4471,8 +4474,8 @@ class ClientController extends AdminController 'dependent_count' => null, 'revenue_type' => $renewalData['revenue_type'] ?? null, 'co_share' => 0, - 'pre_payable_by' => 1, - 'bro_payable_by' => 1, + 'pre_payable_by' => 1, + 'bro_payable_by' => 1, 'tsi' => '500000', 'status' => 'completed', 'ct_status' => 0, @@ -4499,22 +4502,23 @@ class ClientController extends AdminController 'month' => '2025-02-01', 'sales_generated_by' => null, 'serviced_by' => null, - 'ct_type' => 1, + 'ct_type' => 1, 'ct_tran_id' => null, 'remarks' => null, - 'cd_ac_pk' =>$renewalData['cd_ac_pk'] ?? null, + 'cd_ac_pk' => $renewalData['cd_ac_pk'] ?? null, 'install_due_date' => null, 'policy_with_corr' => 0 ]; - + // kint::dump($data); + // dd($data); $policyTransactionModel = new PolicyTransactionModel(); $id = $policyTransactionModel->insert($data); return $id; } private function prepareVehicleData($renewalData) - { + { $vehicleData = [ 'vehicle_no' => $renewalData['veh_no'], 'type' => null, @@ -4524,14 +4528,16 @@ class ClientController extends AdminController 'old_owner' => null, 'rc' => null, ]; - + + + // dd($vehicleData); $VehicleModel = new VehicleModel(); $id = $VehicleModel->insert($vehicleData); return $id; } private function preparePtCoShareDetails($renewalData) - { + { $pt_co_share_details = [ 'pt_id' => $renewalData['pt_id'], @@ -4587,7 +4593,6 @@ class ClientController extends AdminController $PTCOShareDetailsModel = new PTCOShareDetailsModel(); $id = $PTCOShareDetailsModel->insert($pt_co_share_details); return $id; - } private function prepareClientPolicy($renewalData) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 53ae3c5b..599ad4dd 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -462,8 +462,12 @@ class TicketController extends BaseController $mail_responce = $this->sendAutoMailTrigger($ticket_id); //send mail to the head for rejected ticket approvel - if($ticket_data['claim_status_id'] == 8){ + if($ticket_data['claim_status_id'] == 8 && $ticket_data['is_head_approved'] == 0){ $this->sendMailToTheHead($ticket_data); + }else{ + $this->myLogger->logme('error', "Head Mail can't be sent"); + $this->myLogger->logme('error', "CLAIM STATUS ID : {data}", ['data' => $ticket_data['claim_status_id']]); + $this->myLogger->logme('error', "IS HEAD APPROVED : {data}", ['data' => $ticket_data['is_head_approved']]); } return $this->respond(['status' => true, 'code' => 200, 'data' => $ticket_data, "message" => "Claim updated successfully", 'mail_responce' => $mail_responce], 200); diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index 196d4a9b..22164dea 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -269,7 +269,7 @@ value="" name="approved_date"> -