From 785ac1bfbe9804a55f0a849ccb4bb7e4435f1eae Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 19 Feb 2025 10:54:45 +0530 Subject: [PATCH] CHANGES_CLAIMS_CHANGES : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 170 +++++++++++++++++- app/Controllers/EmployeeController.php | 16 +- app/Controllers/EmployeeServiceController.php | 4 +- app/Helpers/excel_util_helper.php | 25 +-- app/Models/EmployeePolicyModel.php | 7 +- app/Views/ticket_form_gmc.php | 137 ++++++++++++-- app/Views/ticket_form_gpa.php | 71 +++++++- 8 files changed, 382 insertions(+), 49 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f6311b6d..c5111235 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -30,6 +30,7 @@ $routes->get("updateRemainderDate", "ClientController::updateRemainderDate"); $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); $routes->get("sendextraparam", "ClientController::sendextraparam"); $routes->get("updateRenewalData", "ClientController::updateRenewalData"); +$routes->get("updateRenewalDataNotExistingClient", "ClientController::updateRenewalDataNotExistingClient"); // $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn"); // $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); // $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 4252cff6..373d8e78 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -660,7 +660,7 @@ class ClientController extends AdminController $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId); - // dd($data['insurerName']); + // dd($data); // print_r($data['depositdata'] );die; // Load the view for the new list page; @@ -691,6 +691,7 @@ class ClientController extends AdminController 'client_id' => $this->request->getPost('client_id'), 'client_policy_id' => null, 'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null, + 'cd_ac_pk' => $CD_Account_Number['id'] ?? null, 'endorsement_no' => null, 'insurer_id' => $this->request->getPost('insurer_id'), 'description' => $this->request->getPost('description'), @@ -3988,12 +3989,17 @@ class ClientController extends AdminController public function sendextraparam() { + + // $employeeController = new EmployeeController(); + // $employeeController->truncateFileData('633'); // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- $employeeRestController = new EmployeeServiceController(); // $employeeRestController->excelFileDataValidation(['file_id' => 823]); - // $employeeRestController->employeesOnboardPreprocess(['file_id' => 823]); + // $employeeRestController->employeesOnboardPreprocess(['file_id' => 835]); + // $employeeRestController->employeesOnboardProcess(['file_id' => 835]); + $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]); // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]); @@ -4472,6 +4478,59 @@ class ClientController extends AdminController $successData[] = ['id' => $value['id'], 'client' => $value['insured']]; } + kint::dump($successData); + } + + public function updateRenewalDataNotExistingClient() + { + $limit = $this->request->getGet('limit') ?? 10; + $group = $this->request->getGet('group') ?? 2; + $db = db_connect(); + $renewalData = $db->table('old_renewal_data_copy') + ->where('client_id IS NULL') + ->where('is_inserted = 0') + ->where('client_type_id', $group) + // ->limit($limit) + ->get() + ->getResultArray(); + // dd($renewalData); + + $successData = []; + foreach ($renewalData as $key => $value) { + + $client_data = $this->clientModel->where('client_name', $value['insured'])->where('is_active', 1)->first(); + if(!empty($client_data)){ + $branch = $this->clientBranchModel->where('client_id', $client_data['id'] ?? 0)->first(); + $value['branch_id'] = $branch['id'] ?? null; + $value['client_id'] = $client_data['id'] ?? null; + }else{ + $value['client_id'] = $this->prepareClient($value); + if($value['client_type_id'] == 1){ + $value['branch_id'] = $this->prepareClientBranch($value); + } + } + + // Fix vehicle_id key (previously "vehicel_id") + if ($value['policy_type_id'] == 8 && !empty($value['policy_type_id'])) { + $value['vehicle_id'] = $this->prepareVehicleData($value); + }else{ + $value['vehicle_id'] = 0; + } + + // 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'], 'vehicle_id' => $value['vehicle_id']]; + } + kint::dump($successData); } @@ -4481,7 +4540,7 @@ class ClientController extends AdminController 'issuer' => $renewalData['issuer_type_id'] ?? null, 'client_id' => $renewalData['client_id'] ?? null, 'client_branch_id' => $renewalData['branch_id'] ?? 0, - 'vehicle_id' => $renewalData['vehicel_id'] ?? null, + 'vehicle_id' => $renewalData['vehicle_id'] ?? null, 'insurer_id' => $renewalData['insurer_id'] ?? null, 'insurer_branch_id' => $renewalData['insurer_branch_id'], 'tpa_id' => null, @@ -4547,20 +4606,36 @@ class ClientController extends AdminController } private function prepareVehicleData($renewalData) - { + { + $VehicleModel = new VehicleModel(); + + if ($renewalData['client_type_id'] == 1) { + $veh_no = explode(" ", $renewalData['insured'])[0] . "_veh_no"; + } else { + $veh_no = $renewalData['insured'] . "_veh_no"; + } + + $vehicleData = $VehicleModel->where('owner', $renewalData['client_id']) + ->where('is_active', 1) + ->findAll(); + + if (!empty($vehicleData)) { + $increment = count($vehicleData); + $veh_no = $increment . "_" . $veh_no; + } + + $vehicleData = [ - 'vehicle_no' => $renewalData['veh_no'], + 'vehicle_no' => $veh_no, 'type' => null, 'description' => null, 'owner' => $renewalData['client_id'], // client_id - 'branch_id' => $renewalData['client_type_id'] == 1 ? $renewalData['branch_id'] : null, // client_branch_id + 'branch_id' => $renewalData['client_type_id'] == 1 ? $renewalData['branch_id'] : 0, // client_branch_id 'old_owner' => null, 'rc' => null, ]; - // dd($vehicleData); - $VehicleModel = new VehicleModel(); $id = $VehicleModel->insert($vehicleData); return $id; } @@ -4628,7 +4703,7 @@ class ClientController extends AdminController { $client_policy = [ 'client_id' => $renewalData['client_id'], - 'client_branch_id' => $renewalData['branch_id'], + 'client_branch_id' => $renewalData['branch_id'] ?? 0, 'policy_type_id' => $renewalData['policy_type_id'], 'insurer_id' => $renewalData['insurer_id'], 'insurer_branch_id' => $renewalData['insurer_branch_id'], @@ -4659,6 +4734,83 @@ class ClientController extends AdminController $id = $ClientPolicyModel->insert($client_policy); return $id; } + + private function prepareClientBranch($renewalData) + { + $branch_code = "BRANCH001"; + $short_name = explode(" ", $renewalData['insured'])[0]; + $unit = $short_name . " - " . $branch_code; + + $clientBranchData = [ + 'client_id' => $renewalData['client_id'], + 'branch_name' => "Branch 1", + 'branch_code' => $branch_code, + 'city' => null, + 'district' => null, + 'state' => null, + 'pincode' => null, + 'address1' => null, + 'address2' => null, + 'gst' => null, + 'sez' => 0, + 'is_active' => 1, + 'units' => $unit + ]; + + + $ClientBranchModel = new ClientBranchModel(); + $id = $ClientBranchModel->insert($clientBranchData); + return $id; + } + + private function prepareClient($renewalData) + { + + if($renewalData['client_type_id'] == 1){ + $short_name = explode(" ", $renewalData['insured'])[0]; + }else{ + $short_name = $renewalData['insured']; + } + + $clientData = [ + 'client_type' => $renewalData['client_type_id'], + 'entity_type_id' => null, + 'client_name' => $renewalData['insured'], + 'short_name' => $short_name, + 'cost_center' => null, + 'client_code' => null, // Auto-generated + 'pan' => null, + 'gst' => null, + 'address1' => null, + 'address2' => null, + 'city' => null, + 'state' => null, + 'pincode' => null, + 'is_download_btn' => 0, // Assuming a default value if not specified + 'client_logo' => null, + 'created_by' => null, + 'created_at' => null, // Will be set automatically by MySQL + 'updated_by' => null, + 'updated_at' => null, // Will be set automatically by MySQL + 'is_active' => 1, // Default value is 1 + 'common_mails' => null, + 'hr_mails' => null, + 'mail_domain' => null, + 'reply_to' => null, + 'dob' => null, + 'aadhar' => null, + 'reference' => null, + 'phone' => null, + 'email' => null, + 'addon_subheading' => null + ]; + + + + $ClientModel = new ClientModel(); + $id = $ClientModel->insert($clientData); + return $id; + } } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index b27a0dae..8262fcb7 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -375,7 +375,7 @@ class EmployeeController extends AdminController ->join('policy_type', 'policy_type.id = client_policy.policy_type_id') ->join('clients', 'clients.id = client_policy.client_id') ->orderBy('batch_files.id', 'desc') - ->limit(100) + ->limit(1000) ->find(); @@ -1298,7 +1298,7 @@ class EmployeeController extends AdminController ->orderBy('id', 'desc') ->first(); - // print_r($file); die; + // dd($cd_tranction, db_connect()->getLastQuery()); if ($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'enrollment' || $file['action'] == 'missed_inception') { @@ -1455,6 +1455,7 @@ class EmployeeController extends AdminController ->get() ->getResult(); + // dd($res); // print_r($this->empEndorsementModel->getLastQuery()); // echo $res[0]->count;die(); @@ -1464,14 +1465,15 @@ class EmployeeController extends AdminController $this->myLogger->logme('error', 'Event Type : -- {data} --', ['data' => $file['action']]); $transaction_type = 'Credit'; - $cd_amount = $cd_tranction['amount']; + $cd_amount = 0; - if($file['action'] == 'deletion'){ + if($file['action'] == 'deletion' && $res[0]->count > 0){ + $transaction_type = 'Debit'; //get cd amount for the particular file id to reverse entry to the cash deposite for only deletion $cd_amount_total = $this->employeePolicyModel->getDeletionDataForTruncated($file['id']); $totalSum = array_sum(array_column($cd_amount_total, 'total')); - $cd_amount = $totalSum; + $cd_amount = $totalSum ?? 0; $this->myLogger->logme('error', 'Deletion CD Amount : {data}', ['data' => $cd_amount]); } @@ -1488,7 +1490,7 @@ class EmployeeController extends AdminController $this->myLogger->logme('error', 'emp_endorsement table updated'); //STEP 2: - if($file['action'] == 'deletion') { + if($file['action'] == 'deletion' && $res[0]->count > 0) { //update the employee policy table reverse the data $this->employeePolicyModel->updateEmployeePolicyTruncateReverse($file_id); $this->myLogger->logme('error', 'employee_polices table updated for deletion'); @@ -1504,7 +1506,7 @@ class EmployeeController extends AdminController $this->myLogger->logme('error', 'files table updated'); - if($cd_tranction && $file['action'] != 'correction'){ + if(!empty($cd_amount) && $file['action'] != 'correction'){ $cd_data = [ 'amount' => $cd_amount, diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index d7674712..fd0c5455 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1647,7 +1647,7 @@ class EmployeeServiceController extends AdminController // echo 'insert emp'; } else - { + { $value['emp_status'] = 'active'; $value['created_by'] = $file['created_by']; $value['client_branch_id'] = $file['client_branch_id']; @@ -2056,6 +2056,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ } $value['family_floater_key'] = $relation; + // dd($value['family_floater_key']); + $policy_data['basic_cover_si'] = $row[9]; $policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],'d-M-Y','Y-m-d') : null; $policy_data['client_policy_id'] = $file['policy_id']; diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 31bb0f1b..a5cd1bda 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -2173,20 +2173,21 @@ if(!function_exists('group_slab_rates_basedon_name')) //this key generating mandantory for display employee info in enrolment app w/o error -if(!function_exists('generate_family_floater_key')) -{ +if (!function_exists('generate_family_floater_key')) { function generate_family_floater_key($relationship) { if (strtolower(trim($relationship)) === 'mother' || strtolower(trim($relationship)) === 'father') { - $relation = 'parent'; - } else if(strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter'){ - $relation = 'child'; - }else if(strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law'){ - $relation = 'parent_in_law'; - }else if(strtolower(trim($relationship)) === 'spouse'){ - $relation = 'spouse'; - }else{ - $relation = 'self'; - } + $relation = 'parent'; + } else if (strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter') { + $relation = 'child'; + } else if (strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') { + $relation = 'parent_in_law'; + } else if (strtolower(trim($relationship)) === 'spouse') { + $relation = 'spouse'; + } else { + $relation = 'self'; + } + + return $relation; } } \ No newline at end of file diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 0f030dae..e0e65966 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -1682,7 +1682,10 @@ class EmployeePolicyModel extends Model // reverse the employee policy table data for the truncated the deletion file public function updateEmployeePolicyTruncateReverse($file_id) - { + { + log_message('error', 'updateEmployeePolicyTruncateReverse model function called'); + log_message('error', 'FILE ID : {data}', ['data' => $file_id]); + $this->db->query(" UPDATE employee_polices SET @@ -1690,7 +1693,7 @@ class EmployeePolicyModel extends Model status = 'active', date_of_exit = NULL, reason_for_exit = NULL, - claim_status = 0, + claim_status = 0 WHERE id IN ( SELECT pk diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index c2543ca2..f72160f1 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -293,6 +293,7 @@ + \ No newline at end of file