diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6eb81acb..0e0c59e7 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -432,6 +432,8 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->get("list/(:any)", "PolicyTransactionController::getInceptionDataForEdit/$1"); $routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1"); $routes->get("removePolicyTransaction/(:any)", "PolicyTransactionController::removePolicyTransaction/$1"); + $routes->match(['get', 'post'], 'list2', 'PolicyTransactionController::viewInception2'); + $routes->get("list2/(:any)", "PolicyTransactionController::getInceptionDataForEdit2/$1"); }); $routes->group("endorsement", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 97a24a24..3233a1dd 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -671,8 +671,9 @@ // Fetch Sales Team $data['salse_team'] = $this->userModel - ->select('user_profiles.*') + ->select('user_profiles.*,nhance_branch.id as nhance_branch_id, nhance_branch.branch_name as nhance_branch_name') ->join('user_teams', 'user_profiles.id = user_teams.user_id') + ->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id','left') ->where('user_teams.team_id', 5) ->where('user_teams.is_active', 1) ->where('user_profiles.is_active', 1) @@ -690,6 +691,7 @@ ->where('is_active', 1) ->findAll(); // echo '
';
+
// print_r($data['ppTeamsData']); die;
// dd($data);
@@ -698,6 +700,160 @@
$this->loadLayout('policy_transaction_inception_list', $data);
}
+ public function viewInception2()
+ {
+ $bds_edit_pt_id = $this->request->getGet('pt_id') ?? null;
+ $data['tab_name'] = 'Policies';
+ $data['page_name'] = 'Policies';
+
+ // 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'] = [
+ 'under_process' => 'Under Process',
+ 'client_pending' => 'Client Pending',
+ 'insurer_pending' => 'Insurer Pending',
+ 'co_insurer_pending' => 'Co-Insurer Pending',
+ 'tpa_pending' => 'TPA Pending',
+ 'validated' => 'Validated',
+ 'cancelled' => 'Cancelled',
+ 'instalment_pending' => 'Instalment Pending',
+ 'completed' => 'Completed',
+ 'lost' => 'Lost',
+ ];
+ $data['invoice_status_array'] = [
+ 'yet_to_generate' => 'Pending',
+ 'generated' => 'Generated',
+ 'send' => 'Sent',
+ 'recived' => 'Payment Received',
+ ];
+ // $data['vehicle_type'] = [
+ // 'two_wheeler' => 'Two Wheeler',
+ // 'four_wheeler' => 'Four Wheeler',
+ // 'truck' => 'Truck',
+ // 'bus' => 'Bus',
+ // 'van' => 'Van',
+ // 'suv' => 'SUV',
+ // 'motorcycle' => 'Motorcycle',
+ // 'bicycle' => 'Bicycle'
+ // ];
+ $data['vehicle_type'] = db_connect()->table('vehicle_type')->where('is_active', 1)->get()->getResultArray();
+ $data['rto_details'] = db_connect()->table('rto_master')->where('is_active', 1)->get()->getResultArray();
+
+ $data['vehicle_des'] = [
+ 'commercial' => 'Commercial',
+ 'private' => 'Private',
+ ];
+ $data['date_type'] = [
+ 'policy_issue_date' => 'Policy Issue Date',
+ 'policy_start_date' => 'Policy Start Date',
+ 'policy_end_date' => 'Policy End Date',
+ ];
+
+ // Filter data
+ $start_date = $this->request->getGet('start_date');
+ $end_date = $this->request->getGet('end_date');
+ $client_id = $this->request->getGet('client_id');
+ $insurer_id = $this->request->getGet('insurer_id');
+ $policy_type_id = $this->request->getGet('policy_type_id');
+ $date_type = $this->request->getGet('date_type');
+ $issuer = $this->request->getGet('issuer');
+ $status = $this->request->getGet('status');
+
+ // Handle null or empty values
+ $start_date = empty($start_date) ? 0 : $start_date;
+ $end_date = empty($end_date) ? 0 : $end_date;
+ $client_id = empty($client_id) ? 0 : $client_id;
+ $insurer_id = empty($insurer_id) ? 0 : $insurer_id;
+ $policy_type_id = empty($policy_type_id) ? 0 : $policy_type_id;
+ $date_type = empty($date_type) ? 0 : $date_type;
+ $issuer = empty($issuer) ? 0 : $issuer;
+ $status = empty($status) ? 0 : $status; // Corrected from `$issuer`
+
+ if(empty($bds_edit_pt_id)){
+ if ($this->request->is('get')) {
+
+ // Fetch inception data list
+ $data['inception_data_list'] = $this->policyTransactionModel->getInceptionTranctionListData(
+ $start_date,
+ $end_date,
+ $client_id,
+ $insurer_id,
+ $policy_type_id,
+ $date_type,
+ $issuer,
+ $status
+ );
+ } else {
+
+ $ids = $this->request->getPost('ids');
+ $ids = array_filter(explode(',', $ids));
+ $data['inception_data_list'] = $this->policyTransactionModel->getInceptionTranctionListData(
+ $start_date = 0,
+ $end_date = 0,
+ $client_id = 0,
+ $insurer_id = 0,
+ $policy_type_id = 0,
+ $date_type = 0,
+ $issuer = 0,
+ $status = 0,
+ $ids
+ );
+ }
+ }else{
+ $data['inception_data_list'] = [];
+ }
+
+
+
+ // Fetch additional data
+ $data['client'] = $this->clientModel->where('is_active', 1)->findAll();
+ $data['client_branch'] = $this->clientBranchModel->where('is_active', 1)->findAll();
+ $data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll();
+ $data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
+ $data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
+ $data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
+ $data['insurer_branch'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
+ $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
+
+ // Fetch PP Teams Data
+ $data['ppTeamsData'] = $this->userModel
+ ->where('is_active', 1)
+ ->findAll();
+
+ // Fetch Sales Team
+ $data['salse_team'] = $this->userModel
+ ->select('user_profiles.*,nhance_branch.id as nhance_branch_id, nhance_branch.branch_name as nhance_branch_name')
+ ->join('user_teams', 'user_profiles.id = user_teams.user_id')
+ ->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id','left')
+ ->where('user_teams.team_id', 5)
+ ->where('user_teams.is_active', 1)
+ ->where('user_profiles.is_active', 1)
+ ->findAll();
+
+ // Fetch Partner Agent
+ $data['partner_agent'] = db_connect()->table('partner_agent')
+ ->where('is_active', 1)
+ ->get()
+ ->getResultArray();
+
+ // Fetch ACM
+ $data['ACM'] = $this->userModel
+ ->where('role', 3) // Assuming `role` is in `user_profiles`
+ ->where('is_active', 1)
+ ->findAll();
+ // echo '';
+
+ // print_r($data['ppTeamsData']); die;
+
+ // dd($data);
+
+ // Load view
+ $this->loadLayout('policy_transaction_inception_list_2', $data);
+ }
+
// policy Transaction Create function start
public function createInceptionPolicy()
{
@@ -1483,6 +1639,276 @@
}
}
+ // Get the Single Inception Tranction data for edit
+ public function getInceptionDataForEdit2($id)
+ {
+ $data = $this->policyTransactionModel
+ ->select('
+ policy_transaction.*,
+ clients.short_name as client_short_name,
+ clients.client_type,
+ clients.entity_type_id,
+ policy_type.policy_type,
+ client_policy.tpa_id as master_tpa_id,
+ client_policy.tpa_branch_id as master_tpa_branch_id,
+ client_policy.policy_type_id as master_policy_type_id,
+ client_policy.is_addon,
+ client_policy.base_policy,
+ (
+ select last_action_date
+ from policy_transaction_status
+ where policy_tran_id = policy_transaction.id
+ and status = policy_transaction.status
+ order by id desc
+ limit 1
+
+ ) as last_action_date
+ ')
+ ->join('clients', 'clients.id = policy_transaction.client_id')
+ ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
+ ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
+ ->where('policy_transaction.id', $id)
+ ->where('policy_transaction.is_active', 1)
+ ->first();
+
+ $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;
+
+ $data['updated_at'] = (isset($data['updated_at']) && $data['updated_at'] !== null && $data['updated_at'] !== '')
+ ? date('d/m/Y h:i:s A', strtotime($data['updated_at']))
+ : null;
+
+
+ if (!empty($data['policy_issue_date'])) {
+ $data['policy_issue_date'] = change_date_format($data['policy_issue_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if (!empty($data['policy_start_date'])) {
+ $data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if (!empty($data['policy_end_date'])) {
+ $data['policy_end_date'] = change_date_format($data['policy_end_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if (!empty($data['renewal_date'])) {
+ $data['renewal_date'] = change_date_format($data['renewal_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if (!empty($data['rollover_date'])) {
+ $data['rollover_date'] = change_date_format($data['rollover_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if (!empty($data['endorse_eff_date'])) {
+ $data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if (!empty($data['last_action_date'])) {
+ $data['last_action_date'] = change_date_format($data['last_action_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if (!empty($data['month'])) {
+ $data['month'] = change_date_format($data['month'], 'Y-m-d', 'M/Y');
+ } else {
+ $data['month'] = null;
+ }
+
+ // print_r($data); die;
+
+ $data['renewal_policy'] = $this->clientPolicyModel
+ ->select('client_policy.*, policy_type.policy_type')
+ ->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
+ ->where('client_policy.client_id', $data['client_id'])
+ ->where('client_policy.client_branch_id', $data['client_branch_id'])
+ ->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')
+ ->where('client_policy.client_id', $data['client_id'])
+ ->where('client_policy.client_branch_id', $data['client_branch_id'])
+ ->whereIn('client_policy.policy_type_id', [2, 3])
+ ->where('client_policy.is_active', 1)
+ ->findAll();
+
+ $pt_bp_amt = $this->PTCOShareDetailsModel
+ ->select('bp_amt, amount')
+ ->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['amount'] ?? null;
+
+
+ $ptFileQuery = $this->PTFileModel
+ ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
+ ->where('pt_files.pt_id', $id)
+ ->where('pt_files.is_active', 1);
+
+ if (!in_array(get_role_id(), [1, 5]) && empty(array_intersect(user_team(), [MANAGEMENT_TEAM_ID, FINANCE_TEAM_ID, BUSINESS_TEAM_ID]))) {
+
+ if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+ $ptFileQuery->where('pt_files.created_by', get_session_userid());
+ }
+ }
+
+ $data['pt_files'] = $ptFileQuery->findAll();
+
+
+
+ $data['pt_co_share_details'] = $this->PTCOShareDetailsModel
+ ->select("
+ pt_co_share_details.*,
+
+ (
+ SELECT
+ COUNT(*)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_stmt_details.co_share_id = pt_co_share_details.id
+ AND co_share_stmt_details.is_active = 1
+ ) AS record_count,
+
+ (
+ SELECT
+ SUM(actual_bp_amt)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_id = pt_co_share_details.id
+ AND is_active = 1
+
+ ) AS actual_bp_amount,
+
+ (
+ SELECT
+ SUM(actual_tp_amt)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_id = pt_co_share_details.id
+ AND is_active = 1
+
+ ) AS actual_tp_amount,
+
+ (
+ SELECT
+ SUM(actual_tep_amt)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_id = pt_co_share_details.id
+ AND is_active = 1
+
+ ) AS actual_tep_amount,
+
+ (
+ SELECT
+ SUM(actual_bp_per)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_id = pt_co_share_details.id
+ AND is_active = 1
+
+ ) AS actual_bp_percentage,
+
+ (
+ SELECT
+ SUM(actual_tp_per)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_id = pt_co_share_details.id
+ AND is_active = 1
+
+ ) AS actual_tp_percentage,
+
+ (
+ SELECT
+ SUM(actual_tep_per)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_id = pt_co_share_details.id
+ AND is_active = 1
+
+ ) AS actual_tep_percentage,
+
+
+ (
+ SELECT
+ SUM(actual_bp_brokerage_amt)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_id = pt_co_share_details.id
+ AND is_active = 1
+
+ ) AS actual_bp_brokerage_amount,
+
+
+ (
+ SELECT
+ SUM(actual_tp_brokerage_amt)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_id = pt_co_share_details.id
+ AND is_active = 1
+
+ ) AS actual_tp_brokerage_amount,
+
+
+ (
+ SELECT
+ SUM(actual_tep_brokerage_amt)
+ FROM
+ co_share_stmt_details
+ WHERE
+ co_share_id = pt_co_share_details.id
+ AND is_active = 1
+
+ ) AS actual_tep_brokerage_amount,
+
+ DATE_FORMAT(pt_policy_issue_date, '%d/%m/%Y') AS pt_policy_issue_date
+
+ ")
+ ->where('pt_id', $id)
+ ->where('is_active', 1)
+ ->orderBy('id', 'asc')
+ ->findAll();
+
+ $data['emp_data'] = $this->employeeModel
+ ->select('employees.*, employee_polices.id as emp_policy_id')
+ ->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
+ ->where('employees.client_id', $data['client_id'])
+ ->where('employees.is_active', 1)->findAll();
+ // $data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
+
+ $clientController = new ClientController();
+ $data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
+ $data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
+
+ $data['vehicle_docs'] = $this->clientKYCDocsModel
+ ->where('client_id', $data['client_id'])
+ ->where('vehicle_id', $data['vehicle_id'])
+ ->findAll();
+
+ // print_r( $data['pt_co_share_details']); die;
+ // return $data;
+ if ($data) {
+ return $this->respond(['status' => true, 'data' => $data], 200);
+ } else {
+ return $this->respond(['status' => false], 200);
+ }
+ }
+
public function removePolicyTransaction($id, $type = 0)
{
if ($id) {
diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php
index d55658d0..43ba28ee 100755
--- a/app/Views/layout/header.php
+++ b/app/Views/layout/header.php
@@ -1890,6 +1890,9 @@