From 11dd30597f32d9c80bd55fd2bf73c123619f33cf Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 18 Sep 2025 18:12:38 +0530 Subject: [PATCH 01/14] CHANGE_BDS : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 286 +++++-- .../PolicyTransactionController.php | 86 ++- app/Controllers/TestingController.php | 77 ++ app/Helpers/excel_util_helper.php | 6 +- app/Models/NhanceBranchModel.php | 51 ++ app/Models/PolicyTransactionModel.php | 1 + .../policy_transaction_inception_form.php | 730 +++++++++++++----- .../policy_transaction_inception_list.php | 31 +- 9 files changed, 975 insertions(+), 294 deletions(-) create mode 100644 app/Models/NhanceBranchModel.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index c217dd5b..05c618bf 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -690,6 +690,7 @@ $routes->group('test', function($routes) { $routes->get('generatePDF', 'TestingController::generatePDF'); $routes->get('viewPDF', 'TestingController::viewPDF'); $routes->get('generate-pdf-view', 'TestingController::generatePDFWithView'); + $routes->get('param/(:any)', 'TestingController::ptedfitdata/$1'); }); $routes->cli('cli/testcli', 'TestingController::testcli'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 8ecf4184..95642959 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -999,31 +999,52 @@ class ClientController extends AdminController $data['client_id'] = $this->request->getPost('client_id'); $data['updated_by'] = get_session_userid(); $inserted = false; + // print_r($this->request->getPost()); die; if ($this->request->getPost('head')) { + $data['user_id'] = $this->request->getPost('head'); - $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('head'), 1); - if ($checkHead) { - $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 1)->set($data)->update(); - } else { - $data['level'] = "1"; - $data['user_id'] = $this->request->getPost('head'); - $inserted = $this->clientRMModel->insert($data); - } + $this->clientRMModel->where('client_id', $id)->where('level', 1)->delete(); + + $data['level'] = "1"; + $data['user_id'] = $this->request->getPost('head'); + $inserted = $this->clientRMModel->insert($data); } if ($this->request->getPost('manager')) { + $data['user_id'] = $this->request->getPost('manager'); - $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('manager'), 2); - if ($checkHead) { - $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 2)->set($data)->update(); - } else { - $data['level'] = "2"; - $data['user_id'] = $this->request->getPost('manager'); - $inserted = $this->clientRMModel->insert($data); - } + $this->clientRMModel->where('client_id', $id)->where('level', 2)->delete(); + + $data['level'] = "2"; + $data['user_id'] = $this->request->getPost('manager'); + $inserted = $this->clientRMModel->insert($data); } + // if ($this->request->getPost('head')) { + // $data['user_id'] = $this->request->getPost('head'); + // $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('head'), 1); + // if ($checkHead) { + // $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 1)->set($data)->update(); + // } else { + // $data['level'] = "1"; + // $data['user_id'] = $this->request->getPost('head'); + // $inserted = $this->clientRMModel->insert($data); + // } + // } + + // if ($this->request->getPost('manager')) { + // $data['user_id'] = $this->request->getPost('manager'); + // $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('manager'), 2); + // if ($checkHead) { + // $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 2)->set($data)->update(); + // } else { + // $data['level'] = "2"; + // $data['user_id'] = $this->request->getPost('manager'); + // $inserted = $this->clientRMModel->insert($data); + // } + // } + if ($this->request->getPost('account_manager')) { $this->clientRMModel->where('client_id', $id)->where('level', 3)->delete(); @@ -4422,7 +4443,7 @@ class ClientController extends AdminController // } // } - public function createClientWithMinimalData() + public function createClientWithMinimalData2() { $postData = $this->request->getPost(); // print_r($postData); die; @@ -4474,7 +4495,74 @@ class ClientController extends AdminController 'name' => $postData['name'], 'mobile' => $postData['mobile'], 'email' => $postData['email'], + ]; + $this->levelContactModel->insert($contact_data); + } + } + return $this->respond([ + 'status' => true, + 'data' => $postData, + 'client_id' => $client_insert, + 'branch_id' => $branch_insert ?? null, + 'message' => 'Client created successfully' + ], 200); + } + + public function createClientWithMinimalData() + { + $postData = $this->request->getPost(); + + // print_r($postData); die; + $client_type = $postData['client_type'] ?? null; + + if($client_type == 2){ + + $client_data = [ + 'client_type' => $postData['client_type'], + 'client_name' => $postData['client_name'], + 'email' => $postData['short_name'] ?? $postData['client_name'], + 'phone' => $postData['mobile'], + 'client_code' => generate_client_code() + ]; + + $client_insert = $this->clientModel->insert($client_data); + + }else if($client_type == 1){ + + $client_data = [ + 'client_type' => $postData['client_type'], + 'client_name' => $postData['client_name'], + 'short_name' => $postData['short_name'] ?? $postData['client_name'], + 'client_code' => generate_client_code(), + 'entity_type_id' => 2 + ]; + + $client_insert = $this->clientModel->insert($client_data); + } + + if (!$client_insert) { + return $this->respond(['status' => false, 'message' => 'Failed to create client'], 200); + } + + // Additional logic for non-individual clients (client_type != 2) + if ($client_type != 2) { + $unit[] = $postData['short_name'] . '-' . 001; + $branch_data = [ + 'client_id' => $client_insert, + 'branch_name' => $postData['branch_name'], + 'branch_code' => 001, + 'gst' => $postData['gst'], + 'units' => json_encode($unit) ?? null, + ]; + + $branch_insert = $this->clientBranchModel->insert($branch_data); + if ($branch_insert) { + $contact_data = [ + 'ref_id' => $branch_insert, + 'contact_type' => 'client', + 'name' => $postData['name'], + 'email' => $postData['email'], ]; $this->levelContactModel->insert($contact_data); } @@ -4508,7 +4596,49 @@ class ClientController extends AdminController $vehicle_insert = $this->vehicleModel->insert($data); if ($vehicle_insert) { - $vehicles = $this->vehicleModel->where('is_active', 1)->findAll(); + + // $vehicles = $this->vehicleModel->where('is_active', 1)->findAll(); + $vehicles = $this->vehicleModel->select('vehicle.*, clients.client_type') + ->join('clients', 'clients.id=vehicle.owner') + ->where('vehicle.is_active', 1) + ->findAll(); + + return $this->respond([ + 'status' => true, + 'vehicle_id' => $vehicle_insert, + 'owner_id' => $data['owner'], + 'owner_branch_id' => $data['branch_id'] ?? null, + 'owner_type' => $data['Owner_type'], + 'vehicles' => $vehicles, + 'message' => 'Vehicle created successfully + ' + ], 200); + } else { + return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200); + } + } + } + + public function createVehicleWithMinimalData2() + { + $data = $this->request->getPost(); + + if (isset($data['client_name']) && !empty($data['client_name'])) { + + $this->clientModel->insert(); + + } else { + + $vehicle_insert = $this->vehicleModel->insert($data); + + if ($vehicle_insert) { + + // $vehicles = $this->vehicleModel->where('is_active', 1)->findAll(); + $vehicles = $this->vehicleModel->select('vehicle.*, clients.client_type') + ->join('clients', 'clients.id=vehicle.owner') + ->where('vehicle.is_active', 1) + ->findAll(); + return $this->respond([ 'status' => true, 'vehicle_id' => $vehicle_insert, @@ -4604,6 +4734,68 @@ class ClientController extends AdminController } } + // public function get_client_policy_data_using_policy_no() + // { + // $received_data = $this->request->getGet(); + // $policy_no = $this->request->getGet('policy_no'); + // $client_id = $this->request->getGet('client_id'); + // $client_branch_id = $this->request->getGet('client_branch_id'); + // $policy_type_id = $this->request->getGet('policy_type_id'); + // $client_type = $this->request->getGet('client_type'); + + // $data = $this->clientPolicyModel + // ->select(" + // client_policy.*, + // policy_type.policy_type, + // clients.client_type, + // clients.client_name, + // DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date, + // DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date + // ") + // ->join('clients', 'client_policy.client_id = clients.id') + // ->join('policy_type', 'client_policy.policy_type_id = policy_type.id') + // ->where('client_policy.policy_no', $policy_no) + // ->where('client_policy.is_active', 1) + // ->where('client_policy.policy_status', 1) + // ->first(); + + // if ($data) { + + // if ($client_type == 1) { + // if ($data['client_id'] == $client_id && $data['client_branch_id'] == $client_branch_id) { + + // if ($data['policy_type_id'] == $policy_type_id) { + // return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200); + // } else { + // $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first(); + // $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.'; + // return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200); + // } + // } else { + // $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check'; + // return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200); + // } + // } else { + // if ($data['client_id'] == $client_id) { + + // if ($data['policy_type_id'] == $policy_type_id) { + // return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200); + // } else { + // $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first(); + // $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.'; + // return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200); + // } + // } else { + // $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check'; + // return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200); + // } + // } + + // } else { + // return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200); + // } + // } + public function get_client_policy_data_using_policy_no() { $received_data = $this->request->getGet(); @@ -4613,54 +4805,14 @@ class ClientController extends AdminController $policy_type_id = $this->request->getGet('policy_type_id'); $client_type = $this->request->getGet('client_type'); - $data = $this->clientPolicyModel - ->select(" - client_policy.*, - policy_type.policy_type, - clients.client_type, - clients.client_name, - DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date, - DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date - ") - ->join('clients', 'client_policy.client_id = clients.id') - ->join('policy_type', 'client_policy.policy_type_id = policy_type.id') - ->where('client_policy.policy_no', $policy_no) - ->where('client_policy.is_active', 1) - ->where('client_policy.policy_status', 1) - ->first(); + $data = $this->policyTransactionModel + ->where('is_active', 1) + ->where('action_type', 'inception') + ->where('policy_no', $policy_no) + ->countAllResults(); - if ($data) { - - if ($client_type == 1) { - if ($data['client_id'] == $client_id && $data['client_branch_id'] == $client_branch_id) { - - if ($data['policy_type_id'] == $policy_type_id) { - return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200); - } else { - $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first(); - $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.'; - return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200); - } - } else { - $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check'; - return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200); - } - } else { - if ($data['client_id'] == $client_id) { - - if ($data['policy_type_id'] == $policy_type_id) { - return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200); - } else { - $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first(); - $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.'; - return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200); - } - } else { - $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check'; - return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200); - } - } - + if ($data > 0) { + return $this->respond(['status' => true, 'message' => 'This policy number is already linked to another client', 'data' => $data, 'code' => 409, 'received_data' => $received_data], 200); } else { return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200); } @@ -5259,7 +5411,7 @@ class ClientController extends AdminController // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- $empServiceController = new EmployeeServiceController(); - // $res = $empServiceController->excelFileFormatValidation(['file_id' => '865']); + $res = $empServiceController->excelFileFormatValidation(['file_id' => '2055']); // $res = $empServiceController->excelFileDataValidation(['file_id' => '865']); // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 726]); // $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]); @@ -5267,7 +5419,7 @@ class ClientController extends AdminController // $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']); // $res = $empServiceController->employeeDisembark(['file_id' => '1681']); // $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']); - // dd( $res); + dd( $res); $EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController(); // $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1069']); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 2b9afb78..e85a8f56 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -36,6 +36,7 @@ use App\Models\BdsPlacementModel; use Kint\Kint; use App\Helpers\MailHelper; use App\Helpers\ExcelSanitizeHelper; +use App\Models\NhanceBranchModel; use Exception; class PolicyTransactionController extends BaseController @@ -69,6 +70,7 @@ class PolicyTransactionController extends BaseController protected $filesModel; protected $coShareStmtDetailsModel; protected $BdsPlacementModel; + protected $nhanceBranchModel; public function __construct() { @@ -100,6 +102,7 @@ class PolicyTransactionController extends BaseController $this->filesModel = new FileModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->BdsPlacementModel = new BdsPlacementModel(); + $this->nhanceBranchModel = new NhanceBranchModel(); $this->invoiceStatus = [ 'pending' => 'Pending', 'generated' => 'Generated', @@ -115,6 +118,7 @@ class PolicyTransactionController extends BaseController // Static arrays for dropdowns $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; + $data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll(); $data['client_type'] = [1 => 'Group', 2 => 'Individual']; $data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over']; $data['policy_status'] = [ @@ -255,6 +259,7 @@ class PolicyTransactionController extends BaseController $id = $this->request->getPost('id'); $data = $this->preparePolicyData(); $data['cd_ac_pk'] = $this->request->getPost('cd_ac_no'); + $data['issuer'] = 2; $this->myLogger->logme('error', 'Policy Trancaction modified form data ( insert data ) : '. json_encode($data)); @@ -334,11 +339,8 @@ class PolicyTransactionController extends BaseController $data['policy_with_corr'] = 1; } - if (!isset($data['is_cd_reduce_from_bds'])) { - $data['is_cd_reduce_from_bds'] = 0; - } elseif ($data['is_cd_reduce_from_bds']) { - $data['is_cd_reduce_from_bds'] = 1; - } + $data['is_cd_reduce_from_bds'] = ($data['policy_type_id'] > 7 && $data['client_type'] === 1) ? 1 : 0; + if ($data['ct_type'] == "") { $data['ct_type'] = 1; @@ -436,6 +438,11 @@ class PolicyTransactionController extends BaseController $data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll(); } + if(isset($data['cd_amt_changed']) && !empty($data['cd_amt_changed'])){ + $policy_data = $this->policyTransactionModel->where('is_active', 1)->where('id', $id)->first(); + $this->cdCorrection($policy_data, $data['cd_amt_changed']); + } + $client_data = $this->clientModel->where('id', $data['client_id'])->first(); $data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll(); @@ -621,6 +628,30 @@ class PolicyTransactionController extends BaseController DepositHelper::saveDeposit($cdTransactionData, get_session_userid()); } + private function cdCorrection($data, $amt) + { + $totalAmount = (int)($amt ?? 0); + $description = 'The following amount of Rs. ' . $totalAmount . '/- has been debited towards the difference arising from the change in the BDS base premium.'; + + $cdTransactionData = [ + 'amount' => abs($totalAmount), + 'sub_type_id' => 4, + 'client_id' => $data['client_id'], + 'client_policy_id' => $data['client_policy_id'] ?? 0, + 'endorsement_no' => null, + 'cd_ac_no' => $data['cd_ac_no'] ?? null, + 'insurer_id' => $data['insurer_id'], + 'description' => $description, + 'transaction_type' => $totalAmount < 0 ? 'Credit' : 'Debit', + 'updated_by' => get_session_userid(), + 'event_name' => 'inception', + 'is_active' => 1, + 'cd_ac_pk' => $data['cd_ac_pk'] + ]; + + DepositHelper::saveDeposit($cdTransactionData, get_session_userid()); + } + private function processInsertIndividualMemberInEmpTable($data) { // print_r($data); @@ -753,31 +784,6 @@ class PolicyTransactionController extends BaseController ->where('policy_transaction.is_active', 1) ->first(); - // $data['policy_issue_date'] = (isset($data['policy_issue_date']) && $data['policy_issue_date'] !== null && $data['policy_issue_date'] !== '') - // ? date('d/m/Y', strtotime($data['policy_issue_date'])) - // : null; - - // $data['policy_start_date'] = (isset($data['policy_start_date']) && $data['policy_start_date'] !== null && $data['policy_start_date'] !== '') - // ? date('d/m/Y', strtotime($data['policy_start_date'])) - // : null; - - // $data['policy_end_date'] = (isset($data['policy_end_date']) && $data['policy_end_date'] !== null && $data['policy_end_date'] !== '') - // ? date('d/m/Y', strtotime($data['policy_end_date'])) - // : null; - - // $data['renewal_date'] = (isset($data['renewal_date']) && $data['renewal_date'] !== null && $data['renewal_date'] !== '') - // ? date('d/m/Y', strtotime($data['renewal_date'])) - // : null; - - // $data['rollover_date'] = (isset($data['rollover_date']) && $data['rollover_date'] !== null && $data['rollover_date'] !== '') - // ? date('d/m/Y', strtotime($data['rollover_date'])) - // : null; - - // $data['month'] = (isset($data['month']) && $data['month'] !== null && $data['month'] !== '') - // ? date('M/Y', strtotime($data['month'])) - // : null; - - $data['created_at'] = (isset($data['created_at']) && $data['created_at'] !== null && $data['created_at'] !== '') ? date('d/m/Y h:i:s A', strtotime($data['created_at'])) : null; @@ -821,8 +827,6 @@ class PolicyTransactionController extends BaseController $data['month'] = null; } - - // print_r($data); die; $data['renewal_policy'] = $this->clientPolicyModel @@ -833,7 +837,6 @@ class PolicyTransactionController extends BaseController ->where('client_policy.is_active', 1) ->findAll(); - $data['base_policy_data'] = $this->clientPolicyModel ->select('client_policy.*, policy_type.policy_type') ->join('policy_type', 'policy_type.id = client_policy.policy_type_id') @@ -843,6 +846,16 @@ class PolicyTransactionController extends BaseController ->where('client_policy.is_active', 1) ->findAll(); + $pt_bp_amt = $this->PTCOShareDetailsModel + ->select('bp_amt') + ->where('pt_id', $id) + ->where('co_share_type', 1) + ->where('is_active', 1) + ->first(); + + // dd(db_connect()->getLastQuery() ,$pt_bp_amt); + $data['base_cd_amount'] = $pt_bp_amt['bp_amt'] ?? null; + $ptFileQuery = $this->PTFileModel ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id') @@ -999,7 +1012,7 @@ class PolicyTransactionController extends BaseController ->findAll(); // print_r( $data['pt_co_share_details']); die; - + // return $data; if ($data) { return $this->respond(['status' => true, 'data' => $data], 200); } else { @@ -1059,8 +1072,8 @@ class PolicyTransactionController extends BaseController // !dd($this->getEndorsementDataForEdit(17)); $data['page_name'] = 'Endorsement'; - $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; + $data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll(); $data['client_type'] = [1 => 'Group', 2 => 'Individual']; $data['policy_status'] = [ @@ -1242,7 +1255,8 @@ class PolicyTransactionController extends BaseController if (!$data['id']) { $data += [ - 'issuer' => $issue_type['issuer'] ?? null, + 'issuer' => 2, + 'issuer_branch' => $data['issuer_branch'] ?? 1, 'client_type' => $data['client_type'] ?? $issue_type['client_type'] ?? null, 'policy_type_id' => $issue_type['policy_type_id'] ?? null, 'issue_type' => $issue_type['issue_type'] ?? null, diff --git a/app/Controllers/TestingController.php b/app/Controllers/TestingController.php index d866cb7f..cb432d24 100644 --- a/app/Controllers/TestingController.php +++ b/app/Controllers/TestingController.php @@ -4,6 +4,7 @@ namespace App\Controllers; use App\Controllers\BaseController; use App\Models\EmployeePolicyModel; +use App\Models\InsurerBranchModel; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\API\ResponseTrait; use Dompdf\Dompdf; @@ -236,4 +237,80 @@ class TestingController extends BaseController ->findAll(); } + + public function ptedfitdata($id){ + $policy_transaction = new PolicyTransactionController(); + $data = $policy_transaction->getInceptionDataForEdit($id); + // dd($data); + $insurerBranchModel = new InsurerBranchModel(); + $insurer_branch = $insurerBranchModel->getInsurerBranchesWithInsurerNames(); + + $dataArray = $data['pt_co_share_details']; // Example + $cd_ac_pk = 'CD12345'; + $role_id = 1; + $team_id = ['6']; + $insurer_branch = $insurer_branch; + + return view('pt_calc_table', [ + 'dataArray' => $dataArray, + 'cd_ac_pk' => $cd_ac_pk, + 'role_id' => $role_id, + 'team_id' => $team_id, + 'insurer_branch' => $insurer_branch + ]); + } + + function generateInsurerTable($dataArray, $cd_ac_pk, $role_id, $team_id, $insurer_branch) + { + $html = ''; + + foreach ($dataArray as $index => $data) { + $disable_td = ($data['record_count'] > 0) ? 'readonly-select' : ''; + $insurer = $data['insurer_branch_id'] . '-' . $data['insurer_id']; + + $html .= ''; + + // Insurer selection + $html .= ''; + + // Leader toggle + $checked = ($data['co_share_type'] == 1) ? 'checked' : ''; + $html .= ''; + + // CD Account + $html .= ''; + + // CD Amount + $html .= ''; + + // Example of follower policy no + $html .= ''; + + // Add other fields (bp_amt, tp_amt, gst, etc.) + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + + $html .= ''; + } + + $html .= '
'; + + return $html; + } + } diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 3b52ce83..932e53c8 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -305,10 +305,12 @@ if (!function_exists('check_si')) { if (!function_exists('check_basic_pay')) { function check_basic_pay($row, $policy_terms, $slab_details) - { + { + // dd($row, $policy_terms, $slab_details); if ($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I', 'A', 'DA', 'MI'])) // check rule only of action column data available { - $is_basic_pay_needed = $slab_details['grid_master']['basicpay']; + // $is_basic_pay_needed = $slab_details['grid_master']['basicpay']; + $is_basic_pay_needed = ($slab_details['grid_master']['basicpay'] == 1 && $slab_details['slab_rates'][0]['si_or_bp'] == 2 && $slab_details['slab_rates'][0]['basic_pay'] != null) ? 1 : 0; // $is_basic_pay_needed = true; $slug = \Config\Services::slug(); $relationship = $slug->slugify($row[5]); diff --git a/app/Models/NhanceBranchModel.php b/app/Models/NhanceBranchModel.php new file mode 100644 index 00000000..d94d5fc9 --- /dev/null +++ b/app/Models/NhanceBranchModel.php @@ -0,0 +1,51 @@ +Back -
+ @@ -173,10 +172,13 @@ + + +
@@ -264,6 +266,19 @@
--> +
+ + +
@@ -272,6 +287,13 @@ +
+
+ + +
+
+
@@ -368,9 +390,8 @@
-
+ +
--> -
- -
+ -
+

@@ -432,16 +452,16 @@
--> -
+ -
+
@@ -573,10 +593,10 @@
-
+