From f99dd816d6fc4a3bb0a2da50aff11f763a016f02 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Wed, 22 Jan 2025 14:38:09 +0530 Subject: [PATCH 01/13] FEAT_CONTROLLER_BDSREPORT_ADDED_SRINIVAS --- app/Controllers/BDSReportController.php | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 app/Controllers/BDSReportController.php diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php new file mode 100644 index 00000000..09e872c3 --- /dev/null +++ b/app/Controllers/BDSReportController.php @@ -0,0 +1,50 @@ +myLogger = \Config\Services::mylogger(); + + $this->clientModel = new ClientModel(); + $this->clientPolicyModel = new ClientPolicyModel(); + $this->insurerModel = new InsurerModel(); + $this->insurerBranchModel = new InsurerBranchModel(); + $this->policyTransactionModel = new PolicyTransactionModel(); + $this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); + $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); + + + } + public function index() + { + // + } + + // ----------------------------------------------------------------------------------------- +} From 560d4328a8a46b5e63e72372ae0fce068afe8dba Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Thu, 23 Jan 2025 18:57:16 +0530 Subject: [PATCH 02/13] FEAT_IRBA_REPORTS_ADDED_SRINIVAS --- app/Config/Routes.php | 9 ++ app/Controllers/BDSReportController.php | 124 ++++++++++++++++- app/Views/bds_report_Insurer_wise_Data.php | 138 +++++++++++++++++++ app/Views/bds_report_bap_wise_data.php | 138 +++++++++++++++++++ app/Views/irba_report.php | 147 +++++++++++++++++++++ app/Views/layout/header.php | 3 + 6 files changed, 555 insertions(+), 4 deletions(-) create mode 100644 app/Views/bds_report_Insurer_wise_Data.php create mode 100644 app/Views/bds_report_bap_wise_data.php create mode 100644 app/Views/irba_report.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 34a9466e..20d56fb4 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -482,3 +482,12 @@ $routes->get("getBackToEnrolledDetails", "EmployeeRestController::getBackToEnrol // Ticketing System // Ticketing System End's + + +//BDSReports +$routes->group("/bdsReport", ["filter" => "authMVC"], function ($routes) { + $routes->match( ['get', 'post'], 'irba_report','BDSReportController::irba_report'); + $routes->get('insurer_wise_data/(:any)','BDSReportController::Insurer_wise_Data/$1'); + $routes->get('bap_wise_data/(:any)','BDSReportController::Bap_Wise_Data/$1'); + +}); diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 09e872c3..96ccb68f 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -14,10 +14,16 @@ use App\Models\InsurerBranchModel; use App\Models\PolicyTransactionModel; use App\Models\PTCOShareDetailsModel; use App\Models\COShareStmtDetailsModel; +use App\Models\PolicyTypeModel; +use CodeIgniter\API\ResponseTrait; -class BDSReportController extends BaseController + +class BDSReportController extends AdminController { + use ResponseTrait; + + protected $myLogger; protected $clientModel; protected $clientPolicyModel; @@ -26,6 +32,7 @@ class BDSReportController extends BaseController protected $policyTransactionModel; protected $PTCOShareDetailsModel; protected $coShareStmtDetailsModel; + protected $policyTypeModel; public function __construct() { @@ -38,13 +45,122 @@ class BDSReportController extends BaseController $this->policyTransactionModel = new PolicyTransactionModel(); $this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); + $this->policyTypeModel = new PolicyTypeModel(); } - public function index() - { - // + public function Insurer_wise_Data($insurerCategory,$fromDate,$toDate){ + + $fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d'); + $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); + + if($insurerCategory == 0 || $insurerCategory == 1){ + $sql = " + select ins.id,ins.name as insurers, + COALESCE(SUM(CASE WHEN pt.action_type = 'inception' and pt.insurer_id = ins.id and ptp.policy_category = $insurerCategory THEN 1 ELSE 0 END), 0) AS Policies, + COALESCE(SUM(CASE WHEN stmt.co_share_id = pt_co.id and ptp.policy_category = $insurerCategory and pt_co.insurer_id = ins.id THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS Premium, + COALESCE(SUM(CASE WHEN stmt.co_share_id = pt_co.id and ptp.policy_category = $insurerCategory and pt_co.insurer_id = ins.id THEN stmt.reward + stmt.actual_bp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.actual_tp_brokerage_amt ELSE 0 END), 0) AS Revenue + from insurers ins + left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 + left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 + left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 and pt.policy_issue_date >= $fromDate and pt.policy_issue_date <= $toDate + left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $insurerCategory + where ins.is_active = 1 and (ptp.policy_category = $insurerCategory or ptp.policy_category is null) + group by ins.id + "; + + $data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray(); + + + }else{ + $data['message'] = 'Insurer Category Not Valid'; + log_message('error',$data['message']); + return $data; + } + return view('bds_report_Insurer_wise_Data',$data); } + public function Bap_Wise_Data($insurerCategory,$fromDate,$toDate){ + $fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d'); + $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); + + if($insurerCategory == 0 || $insurerCategory == 1){ + $sql = " + SELECT + pot.bap AS bap, + COALESCE(COUNT(DISTINCT pt.id), 0) AS Policies, + COALESCE(SUM(co.actual_bp_amt + co.actual_tep_amt + co.actual_tp_amt), 0) AS Premium, + COALESCE(SUM(co.reward + co.actual_bp_brokerage_amt + co.actual_tep_brokerage_amt + co.actual_tp_brokerage_amt), 0) AS Revenue + FROM policy_type AS pot + LEFT JOIN policy_transaction AS pt ON pot.id = pt.policy_type_id AND pt.is_active = 1 AND pt.action_type = 'inception' and pt.policy_issue_date >= $fromDate and pt.policy_issue_date <= $toDate + LEFT JOIN pt_co_share_details AS ptco ON pt.id = ptco.pt_id AND ptco.is_active = 1 + LEFT JOIN co_share_stmt_details AS co ON ptco.id = co.co_share_id AND co.is_active = 1 + WHERE pot.is_active = 1 + AND pot.policy_category = $insurerCategory + GROUP BY pot.bap; + + "; + $data['bap_wise_data'] = $this->policyTypeModel->query($sql)->getResultArray(); + }else{ + $data['message'] = 'Insurer Category Not Valid'; + log_message('error',$data['message']); + return $data; + } + + + return view('bds_report_bap_wise_data',$data); + } + + public function irba_report(){ + + if ($this->request->getMethod()=='get'){ + $default_start = new \DateTime(); + $data['default_end'] = $default_start->format('d-m-Y'); + $data['default_start'] = $default_start->modify('-90 days')->format('d-m-Y'); + $data['categories'] = [ + 'Life' => 'life','Non Life'=>'nonLife' + ]; + $data['report_type'] = [ + 'Insurer'=> 'insurer', + 'BAP' => 'bap', + 'BAP-Client' => 'bapClient', + 'BAP-Insurer' =>'bapInsurer', + 'Client' =>'client' + ]; + return $this->loadLayout('irba_report',$data); + }else{ + $fromDate = $this->request->getPost('fromDate'); + $toDate = $this->request->getPost('toDate'); + $category = $this->request->getPost('category'); + $report_type = $this->request->getPost('report_type'); + // log_message('error',json_encode($_POST));die(); + if($report_type == 'insurer'){ + $life = $category == 'life' ? 1:0; + $viewData = $this->Insurer_wise_Data($life,$fromDate,$toDate); + + // Ensure $viewData is an array + if (!is_array($viewData)) { + $viewData = []; + } + + $html = view('bds_report_Insurer_wise_Data', $viewData); + return $this->respond(['status'=>true, 'html'=>$html], 200); + } + else if($report_type == 'bap'){ + $life = $category == 'life'?1:0; + $viewData = $this->Bap_wise_Data($life,$fromDate,$toDate); + + // Ensure $viewData is an array + if (!is_array($viewData)) { + $viewData = []; + } + + $html = view('bds_report_bap_wise_data', $viewData); + return $this->respond(['status'=>true, 'html'=>$html], 200); + } + + } +} + // ----------------------------------------------------------------------------------------- } diff --git a/app/Views/bds_report_Insurer_wise_Data.php b/app/Views/bds_report_Insurer_wise_Data.php new file mode 100644 index 00000000..f93e5c55 --- /dev/null +++ b/app/Views/bds_report_Insurer_wise_Data.php @@ -0,0 +1,138 @@ + +
+
+
+
+
+

Employees

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
InsurerPoliciesPremiumRevenue
Total Amount
+
+
+
+
+ + diff --git a/app/Views/bds_report_bap_wise_data.php b/app/Views/bds_report_bap_wise_data.php new file mode 100644 index 00000000..b05960a8 --- /dev/null +++ b/app/Views/bds_report_bap_wise_data.php @@ -0,0 +1,138 @@ + +
+
+
+
+
+

Employees

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
InsurerPoliciesPremiumRevenue
Total Amount
+
+
+
+
+ + + diff --git a/app/Views/irba_report.php b/app/Views/irba_report.php new file mode 100644 index 00000000..88f51ebb --- /dev/null +++ b/app/Views/irba_report.php @@ -0,0 +1,147 @@ +
+
+
+
+
+ + + +
+
+
+ +
+
+ +
+   + +
+ > + > +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ +
+ Submit +
+
+ +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index e8f0dd11..02c29f7d 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -717,6 +717,9 @@
  • Outstanding
  • +
  • + IRBA Reports +
  • From 09b3963653a04f3b1badebe8d015e97878d0681d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 24 Jan 2025 08:33:39 +0530 Subject: [PATCH 03/13] CHANGE_IRDA_REPORT_INS_CLT : RV --- app/Controllers/BDSReportController.php | 284 +++++++++++++++++- app/Controllers/ClientController.php | 14 + .../PolicyTransactionController.php | 21 +- app/Models/PolicyTypeModel.php | 2 +- app/Views/irda_bap_client_report_list.php | 226 ++++++++++++++ app/Views/irda_bap_insurer_report_list.php | 234 +++++++++++++++ app/Views/irda_client_report_list.php | 148 +++++++++ .../policy_transaction_endorsement_form.php | 21 +- .../policy_transaction_endorsement_list.php | 8 +- .../policy_transaction_inception_form.php | 33 +- 10 files changed, 964 insertions(+), 27 deletions(-) create mode 100644 app/Views/irda_bap_client_report_list.php create mode 100644 app/Views/irda_bap_insurer_report_list.php create mode 100644 app/Views/irda_client_report_list.php diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 09e872c3..dfcf2791 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -46,5 +46,287 @@ class BDSReportController extends BaseController // } - // ----------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + + //Function for get BAP INSURE wise data for premium , policy count , revenue only + public function getBAPInsurerData($category = 0, $start_date = null, $end_date = null) + { + try { + $this->myLogger->logme('error', 'getBAPInsurerData function called'); + $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = $start_date; + $toDate = $end_date; + } + + $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + $db = db_connect(); + $builder = $db->query(" + + select ins.id, ins.name as insurer_name, + + -- Health Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS health_revenue, + + -- Misc Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS misc_revenue, + + + -- Motor Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS motor_revenue, + + -- Engineering Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS engineering_revenue, + + + -- Fire Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS fire_revenue, + + -- Liability Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS liability_revenue, + + + -- Life Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS life_revenue, + + + -- Marine Cargo Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_cargoe_revenue, + + -- Marine Hull Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_hull_revenue + + from insurers ins + left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 + left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 + left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' + left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $category + where ins.is_active = 1 + group by ins.id + ORDER BY + health_premium DESC, + misc_premium DESC, + motor_premium DESC, + engineering_premium DESC, + fire_premium DESC, + liability_premium DESC, + life_premium DESC, + marine_cargo_premium DESC, + marine_hull_premium DESC; + + "); + + // Get the query + $result = $builder->getResultArray(); + $this->myLogger->logme('error', 'Query executed successfully.'); + // dd(db_connect()->getLastQuery(),$result); + return $result; + + } catch (\Exception $e) { + + // Log the exception details for debugging + $this->myLogger->logme('error', 'Error occurred in getBAPInsurerData: {message}', ['message' => $e->getMessage()]); + $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + return []; + } + } + + //Function for get BAP CLIENT wise data for premium , policy count , revenue only + public function getBAPClientData($category = 0, $start_date = null, $end_date = null) + { + + try { + $this->myLogger->logme('error', 'getBAPClientData function called'); + $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = $start_date; + $toDate = $end_date; + } + + $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + $db = db_connect(); + $builder = $db->query(" + + SELECT + c.id AS client_id, + c.client_name, + + -- Health Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + + -- Misc Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + + -- Motor Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + + -- Engineering Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + + -- Fire Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + + -- Liability Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + + -- Life Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + + -- Marine Cargo Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + + -- Marine Hull Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium + + FROM clients c + LEFT JOIN policy_transaction pt ON pt.client_id = c.id AND pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' + LEFT JOIN policy_type ptp ON pt.policy_type_id = ptp.id + LEFT JOIN pt_co_share_details ptco ON ptco.pt_id = pt.id AND ptco.is_active = 1 + LEFT JOIN co_share_stmt_details stmt ON stmt.co_share_id = ptco.id AND stmt.is_active = 1 + WHERE c.is_active = 1 + AND ptp.policy_category = $category + GROUP BY c.id + ORDER BY + health_premium DESC, + misc_premium DESC, + motor_premium DESC, + engineering_premium DESC, + fire_premium DESC, + liability_premium DESC, + life_premium DESC, + marine_cargo_premium DESC, + marine_hull_premium DESC + + "); + + // Get the query + $result = $builder->getResultArray(); + // dd(db_connect()->getLastQuery(),$result); + return $result; + } catch (\Exception $e) { + + // Log the exception details for debugging + $this->myLogger->logme('error', 'Error occurred in getBAPClientData: {message}', ['message' => $e->getMessage()]); + $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + return []; + } + } + + //Function for get CLIENT wise data for premium and policy count only + public function getClientData($category = 0, $start_date = null, $end_date = null) + { + + try { + + $this->myLogger->logme('error', 'getClientData function called'); + $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = $start_date; + $toDate = $end_date; + } + + $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + $db = db_connect(); + $builder = $db->query(" + + select + c.id as client_id, + c.client_name, + + ( + select + count(policy_transaction.id) + from policy_transaction + left join policy_type on policy_transaction.policy_type_id = policy_type.id + where policy_transaction.client_id = c.id + and policy_transaction.action_type = 'inception' + and policy_transaction.is_active = 1 + + ) as policy_count, + + COALESCE(( + select + sum(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt) as premium + from co_share_stmt_details stmt + left join pt_co_share_details ptco on stmt.co_share_id = ptco.id + left join policy_transaction pt on ptco.pt_id = pt.id + where pt.client_id = c.id + and stmt.is_active = 1 + and ptco.is_active = 1 + and pt.is_active = 1 + + ), 0) as premium + + from clients c + join policy_transaction on c.id = policy_transaction.client_id + join policy_type on policy_transaction.policy_type_id = policy_type.id + where c.is_active = 1 + and policy_type.policy_category = $category + AND policy_transaction.policy_issue_date >= '$fromDate' + AND policy_transaction.policy_issue_date <= '$toDate' + group by client_name + order by premium desc + "); + + // Get the query + $result = $builder->getResultArray(); + // dd(db_connect()->getLastQuery(),$result); + return $result; + } catch (\Exception $e) { + + // Log the exception details for debugging + $this->myLogger->logme('error', 'Error occurred in getClientData: {message}', ['message' => $e->getMessage()]); + $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + return []; + } + } } diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index eab0a10b..d6d1626a 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4045,6 +4045,20 @@ class ClientController extends AdminController // $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name); // dd($returndata); + // -----------BDS REPORT CONTROLLER--------------------------------------------------------------------------------- + + $BDSReportController = new BDSReportController(); + + $data['data'] = $BDSReportController->getBAPInsurerData(); + return $this->loadLayout('irda_bap_insurer_report_list', $data); + + // $data['data'] = $BDSReportController->getBAPClientData(); + // return $this->loadLayout('irda_bap_client_report_list', $data); + + // $data['data'] = $BDSReportController->getClientData(); + // return $this->loadLayout('irda_client_report_list', $data); + + // $BDSReportController->getBAPClientData(); } // ------------------------------------------------------------------------------------------------------- diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index ca4a1d66..8a03a1e4 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1103,20 +1103,30 @@ class PolicyTransactionController extends BaseController } - if(!empty($data['data_received_date'])){ + if(empty($data['data_received_date'])){ + $data['data_received_date'] = null; + }else{ $data['data_received_date'] = change_date_format($data['data_received_date'], 'd/m/Y', 'Y-m-d'); } - if(!empty($data['policy_issue_date'])){ + if(empty($data['policy_issue_date'])){ + $data['policy_issue_date'] = null; + }else{ $data['policy_issue_date'] = change_date_format($data['policy_issue_date'], 'd/m/Y', 'Y-m-d'); } - if(!empty($data['endorse_eff_date'])){ + if(empty($data['endorse_eff_date'])){ + $data['endorse_eff_date'] = null; + }else{ $data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'd/m/Y', 'Y-m-d'); + } - if(!empty($data['install_due_date'])){ + if(empty($data['install_due_date'])){ + $data['install_due_date'] = null; + }else{ $data['install_due_date'] = change_date_format($data['install_due_date'], 'd/m/Y', 'Y-m-d'); + } if(!empty($data['month'])){ @@ -1162,7 +1172,8 @@ class PolicyTransactionController extends BaseController 'policy_type_id' => $issue_type['policy_type_id'] ?? null, 'issue_type' => $issue_type['issue_type'] ?? null, 'source_client_policy_id' => $issue_type['source_client_policy_id'] ?? null, - 'cd_ac_no' => $issue_type['issue_type'] ?? null, + 'cd_ac_no' => $issue_type['cd_ac_no'] ?? null, + 'cd_ac_pk' => $issue_type['cd_ac_pk'] ?? null, // 'policy_issue_date' => $issue_type['policy_issue_date'] ?? null, 'policy_start_date' => $issue_type['policy_start_date'] ?? null, 'policy_end_date' => $issue_type['policy_end_date'] ?? null, diff --git a/app/Models/PolicyTypeModel.php b/app/Models/PolicyTypeModel.php index 29126484..90aa1758 100755 --- a/app/Models/PolicyTypeModel.php +++ b/app/Models/PolicyTypeModel.php @@ -22,6 +22,6 @@ class PolicyTypeModel extends Model "etp", "iep", "itp", - "question_json",'itep','etep' + "question_json",'itep','etep', 'policy_category', ]; } diff --git a/app/Views/irda_bap_client_report_list.php b/app/Views/irda_bap_client_report_list.php new file mode 100644 index 00000000..6ecbf234 --- /dev/null +++ b/app/Views/irda_bap_client_report_list.php @@ -0,0 +1,226 @@ + + +
    +
    +
    +
    +
    +

    BAP Client Report

    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EngineeringFireHealthLiabilityLifeMarine CargoMiscMotorMarine Hull
    S. NoInsuredPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremium
    + +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/app/Views/irda_bap_insurer_report_list.php b/app/Views/irda_bap_insurer_report_list.php new file mode 100644 index 00000000..6321f7a1 --- /dev/null +++ b/app/Views/irda_bap_insurer_report_list.php @@ -0,0 +1,234 @@ + + +
    +
    +
    +
    +
    +

    BAP Insurer Report

    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EngineeringFireHealthLiabilityLifeMarine CargoMiscMotorMarine Hull
    S. NoInsurerPoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenue
    + +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/app/Views/irda_client_report_list.php b/app/Views/irda_client_report_list.php new file mode 100644 index 00000000..70ba446f --- /dev/null +++ b/app/Views/irda_client_report_list.php @@ -0,0 +1,148 @@ + + +
    +
    +
    +
    +
    +

    Client Report

    +
    + +
    +
    + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + +
    S. NoInsuredPoliciesPremium
    + +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 687891b4..c9d439b9 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -1159,17 +1159,20 @@ function amountCalculation(input) { console.log('gst_per_amt', gst_per_amt); // $('#gst_amount_' + input).val(gst_per_amt.toFixed(2)); - if(gst_amount != 0){ - if (event.target.id.startsWith('non_comm_per_amt')) { + if (event.target.id.startsWith('non_comm_per_amt')) { + $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); + }else if (event.target.id.startsWith('gst_amount')) { + $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + }else{ + if(ncpa != 0 && ncpa != ""){ $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); }else{ - $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + $('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00'); } - }else{ - $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); } + let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt; console.log('Summed Amount:', finalTotal); @@ -1186,11 +1189,15 @@ function amountCalculation(input) { expectedAmount = agreed_amount; // console.log('Formula 1 AGREED AMOUNT'); }else if(sum_of_agreed_premium > 0){ - expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + //expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per; + expectedAmount = (tpTotal * sumOfTheAggreedPer); expectedAmount = expectedAmount / 100; // console.log('Formula 2 AGREED BP TP/TEP %'); }else{ - expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + // expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per; + expectedAmount = (tpTotal * sumOfTheStandardPer); console.log(expectedAmount) expectedAmount = expectedAmount / 100; // console.log('Formula 3 STANDARD BP TP/TEP %'); diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index e08cb097..f1f00d52 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -548,10 +548,10 @@ document.addEventListener("DOMContentLoaded", function () { }); - // var closure_date = flatpickr("#policy_issue_date", { - // dateFormat: "d/m/Y", - // allowInput: false - // }); + var closure_date = flatpickr("#policy_issue_date", { + dateFormat: "d/m/Y", + allowInput: false + }); var install_due_date = flatpickr("#install_due_date", { dateFormat: "d/m/Y", diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 30df9f5a..af9416a2 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1842,17 +1842,20 @@ function amountCalculation(input) { console.log('gst_per_amt', gst_per_amt); // $('#gst_amount_' + input).val(gst_per_amt.toFixed(2)); - if(gst_amount != 0){ - if (event.target.id.startsWith('non_comm_per_amt')) { + if (event.target.id.startsWith('non_comm_per_amt')) { + $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); + }else if (event.target.id.startsWith('gst_amount')) { + $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + }else{ + if(ncpa != 0 && ncpa != ""){ $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); }else{ - $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + $('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00'); } - }else{ - $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); } + let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt; console.log('Summed Amount:', finalTotal); @@ -1869,11 +1872,15 @@ function amountCalculation(input) { expectedAmount = agreed_amount; // console.log('Formula 1 AGREED AMOUNT'); }else if(sum_of_agreed_premium > 0){ - expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + //expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per; + expectedAmount = (tpTotal * sumOfTheAggreedPer); expectedAmount = expectedAmount / 100; // console.log('Formula 2 AGREED BP TP/TEP %'); }else{ - expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + // expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per; + expectedAmount = (tpTotal * sumOfTheStandardPer); console.log(expectedAmount) expectedAmount = expectedAmount / 100; // console.log('Formula 3 STANDARD BP TP/TEP %'); @@ -3890,9 +3897,11 @@ function populateTable(dataArray, cd_ac_pk) { case 2: // CD Account Number cell.find('select').val(cd_ac_pk); var selectElement = cell.find('select'); + console.log('selectElement', selectElement); selectElement.val(cd_ac_pk).prop('selected', true); selectElement.toggleClass('readonly-select', !!disable_td) setTimeout(function(){ + console.log('selectElement', selectElement); selectElement.find('option[value="' + cd_ac_pk + '"]').prop('selected', true); selectElement.toggleClass('readonly-select', !!disable_td) }, 2000) @@ -4240,8 +4249,14 @@ function getCdAmount(cd_ac_pk, increment){ console.log('Data fetched successfully:', response); if (response.status == true) { - $('#cd_current_balance_'+increment).val(response.data.balance); - } + if(!response.data.balance){ + $('#cd_current_balance_'+increment).val(0.00); + }else{ + $('#cd_current_balance_'+increment).val(response.data.balance); + } + } else{ + $('#cd_current_balance_'+increment).val(0.00); + } }, function(xhr, status, error) { console.error('Error fetching data:', error); From c73564ec723a37c629aca2a190bc7d6e337af139 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 24 Jan 2025 09:52:14 +0530 Subject: [PATCH 04/13] FEAT_IRDA_REPORT_SRINIVAS --- app/Controllers/BDSReportController.php | 93 ++++----- app/Views/bds_report_Insurer_wise_Data.php | 153 +++++++------- app/Views/bds_report_bap_wise_data.php | 159 +++++++-------- app/Views/irba_report.php | 112 ++++++----- app/Views/layout/header.php | 219 +++++++++++---------- 5 files changed, 367 insertions(+), 369 deletions(-) diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 96ccb68f..8fbb8f3e 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -46,15 +46,13 @@ class BDSReportController extends AdminController $this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->policyTypeModel = new PolicyTypeModel(); - - } - public function Insurer_wise_Data($insurerCategory,$fromDate,$toDate){ + public function Insurer_wise_Data($insurerCategory, $fromDate, $toDate) + { $fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d'); $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); - - if($insurerCategory == 0 || $insurerCategory == 1){ + try { $sql = " select ins.id,ins.name as insurers, COALESCE(SUM(CASE WHEN pt.action_type = 'inception' and pt.insurer_id = ins.id and ptp.policy_category = $insurerCategory THEN 1 ELSE 0 END), 0) AS Policies, @@ -63,28 +61,29 @@ class BDSReportController extends AdminController from insurers ins left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 - left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 and pt.policy_issue_date >= $fromDate and pt.policy_issue_date <= $toDate + left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate' left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $insurerCategory where ins.is_active = 1 and (ptp.policy_category = $insurerCategory or ptp.policy_category is null) group by ins.id "; - - $data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray(); - - - }else{ - $data['message'] = 'Insurer Category Not Valid'; - log_message('error',$data['message']); + + $data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray(); + // log_message('error',$this->insurerModel->getLastQuery()); + // log_message('error',json_encode($data)); + } catch (\Exception $e) { + $data['message'] = 'No data Found'; + $this->myLogger->logme('error', $e->getMessage()); return $data; } - return view('bds_report_Insurer_wise_Data',$data); + return ($data); } - public function Bap_Wise_Data($insurerCategory,$fromDate,$toDate){ + public function Bap_Wise_Data($insurerCategory, $fromDate, $toDate) + { $fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d'); $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); - if($insurerCategory == 0 || $insurerCategory == 1){ + try { $sql = " SELECT pot.bap AS bap, @@ -92,7 +91,7 @@ class BDSReportController extends AdminController COALESCE(SUM(co.actual_bp_amt + co.actual_tep_amt + co.actual_tp_amt), 0) AS Premium, COALESCE(SUM(co.reward + co.actual_bp_brokerage_amt + co.actual_tep_brokerage_amt + co.actual_tp_brokerage_amt), 0) AS Revenue FROM policy_type AS pot - LEFT JOIN policy_transaction AS pt ON pot.id = pt.policy_type_id AND pt.is_active = 1 AND pt.action_type = 'inception' and pt.policy_issue_date >= $fromDate and pt.policy_issue_date <= $toDate + LEFT JOIN policy_transaction AS pt ON pot.id = pt.policy_type_id AND pt.is_active = 1 AND pt.action_type = 'inception' and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate' LEFT JOIN pt_co_share_details AS ptco ON pt.id = ptco.pt_id AND ptco.is_active = 1 LEFT JOIN co_share_stmt_details AS co ON ptco.id = co.co_share_id AND co.is_active = 1 WHERE pot.is_active = 1 @@ -101,66 +100,70 @@ class BDSReportController extends AdminController "; $data['bap_wise_data'] = $this->policyTypeModel->query($sql)->getResultArray(); - }else{ - $data['message'] = 'Insurer Category Not Valid'; - log_message('error',$data['message']); + } catch (\Exception $e) { + $data['message'] = 'No Data Found'; + $this->myLogger->logme('error', $e->getMessage()); return $data; } - - return view('bds_report_bap_wise_data',$data); + + return ($data); } - public function irba_report(){ + public function irba_report() + { - if ($this->request->getMethod()=='get'){ + if ($this->request->is('get')) { $default_start = new \DateTime(); $data['default_end'] = $default_start->format('d-m-Y'); $data['default_start'] = $default_start->modify('-90 days')->format('d-m-Y'); $data['categories'] = [ - 'Life' => 'life','Non Life'=>'nonLife' + 'Life' => 'life', + 'Non Life' => 'nonLife' ]; $data['report_type'] = [ - 'Insurer'=> 'insurer', + 'Insurer' => 'insurer', 'BAP' => 'bap', 'BAP-Client' => 'bapClient', - 'BAP-Insurer' =>'bapInsurer', - 'Client' =>'client' + 'BAP-Insurer' => 'bapInsurer', + 'Client' => 'client' ]; - return $this->loadLayout('irba_report',$data); - }else{ + return $this->loadLayout('irba_report', $data); + } else { $fromDate = $this->request->getPost('fromDate'); $toDate = $this->request->getPost('toDate'); $category = $this->request->getPost('category'); $report_type = $this->request->getPost('report_type'); // log_message('error',json_encode($_POST));die(); - if($report_type == 'insurer'){ - $life = $category == 'life' ? 1:0; - $viewData = $this->Insurer_wise_Data($life,$fromDate,$toDate); - + if ($report_type == 'insurer') { + $life = $category == 'life' ? 1 : 0; + $viewData = $this->Insurer_wise_Data($life, $fromDate, $toDate); + if (isset($data['message'])) { + return $this->respond(['status'=> false,'message'=>$data['message']],200); + } // Ensure $viewData is an array if (!is_array($viewData)) { $viewData = []; } - + $html = view('bds_report_Insurer_wise_Data', $viewData); - return $this->respond(['status'=>true, 'html'=>$html], 200); - } - else if($report_type == 'bap'){ - $life = $category == 'life'?1:0; - $viewData = $this->Bap_wise_Data($life,$fromDate,$toDate); - + return $this->respond(['status' => true, 'html' => $html], 200); + } else if ($report_type == 'bap') { + $life = $category == 'life' ? 1 : 0; + $viewData = $this->Bap_wise_Data($life, $fromDate, $toDate); + if (isset($data['message'])) { + return $this->respond(['status'=> false,'message'=>$data['message']],200); + } // Ensure $viewData is an array if (!is_array($viewData)) { $viewData = []; } - + $html = view('bds_report_bap_wise_data', $viewData); - return $this->respond(['status'=>true, 'html'=>$html], 200); + return $this->respond(['status' => true, 'html' => $html], 200); } - + } } -} // ----------------------------------------------------------------------------------------- } diff --git a/app/Views/bds_report_Insurer_wise_Data.php b/app/Views/bds_report_Insurer_wise_Data.php index f93e5c55..2e7d9cff 100644 --- a/app/Views/bds_report_Insurer_wise_Data.php +++ b/app/Views/bds_report_Insurer_wise_Data.php @@ -1,5 +1,4 @@ +
    -
    -
    -
    -
    -

    Employees

    -
    +
    +
    +
    +
    +

    Employees

    -
    +
    +
    @@ -48,91 +47,85 @@ table.dataTable tbody td { - + - + - + - +
    Total AmountGrand Total
    +
    -
    + - diff --git a/app/Views/bds_report_bap_wise_data.php b/app/Views/bds_report_bap_wise_data.php index b05960a8..a75fc389 100644 --- a/app/Views/bds_report_bap_wise_data.php +++ b/app/Views/bds_report_bap_wise_data.php @@ -1,5 +1,4 @@ +
    -
    -
    -
    -
    -

    Employees

    -
    +
    +
    +
    +
    +

    Employees

    -
    - + +
    +
    + @@ -47,92 +47,85 @@ table.dataTable tbody td { - + - + - + - +
    Insurer Policies
    Total AmountGrand Total
    +
    -
    + - + // Calculate total for each column + var totalPolicies = api.column(1).data().reduce(function(a, b) { + return parseNumber(a) + parseNumber(b); + }, 0); + var totalPremium = api.column(2).data().reduce(function(a, b) { + return parseNumber(a) + parseNumber(b); + }, 0); + + var totalRevenue = api.column(3).data().reduce(function(a, b) { + return parseNumber(a) + parseNumber(b); + }, 0); + + // Update the footer with totals + $(api.column(1).footer()).html(totalPolicies.toLocaleString()); + $(api.column(2).footer()).html("₹ " + totalPremium.toLocaleString(undefined, { minimumFractionDigits: 2 })); + $(api.column(3).footer()).html("₹ " + totalRevenue.toLocaleString(undefined, { minimumFractionDigits: 2 })); + } + }); + } else { + console.error("Table not found."); + } + }); + \ No newline at end of file diff --git a/app/Views/irba_report.php b/app/Views/irba_report.php index 88f51ebb..97ee9cd5 100644 --- a/app/Views/irba_report.php +++ b/app/Views/irba_report.php @@ -12,15 +12,15 @@
    -
    - -
    -   - -
    - > - > +
    + +
    +   +
    + > + > +
    @@ -28,19 +28,19 @@
    - +

    @@ -59,8 +59,10 @@
    -
    +
    +
    +
    \ No newline at end of file diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 02c29f7d..690cedc5 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -60,7 +60,7 @@ - + @@ -75,17 +75,15 @@ }); } - - - - - - - - + + + + + + + + +
    +
    +
    +
    + +
    +
    +

    Ticket

    +
    +
    + + + +
    +
    + + + + + +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + +
    + +
    \ No newline at end of file diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php new file mode 100644 index 00000000..8c381b92 --- /dev/null +++ b/app/Views/ticket_form_gmc.php @@ -0,0 +1,246 @@ +
    +
    +
    "> +
    + +
    +
    +

    Claim GMC

    +
    +
    + +
    +
    +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    +
    +
    + +
    + +
    + +
    +
    +
    diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php new file mode 100644 index 00000000..6cac4d51 --- /dev/null +++ b/app/Views/ticket_form_gpa.php @@ -0,0 +1,173 @@ +
    +
    +
    "> +
    + +
    +
    +

    Claim GPA

    +
    +
    + +
    +
    +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/app/Views/ticket_history.php b/app/Views/ticket_history.php new file mode 100644 index 00000000..73e0850b --- /dev/null +++ b/app/Views/ticket_history.php @@ -0,0 +1,33 @@ +
    +
    +
    +
    + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + +
    FieldOld ValueNew ValueUserDate/Time
    +
    +
    +
    +
    diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php new file mode 100644 index 00000000..69bacaf5 --- /dev/null +++ b/app/Views/ticket_list.php @@ -0,0 +1,136 @@ + + +
    +
    +
    +
    +
    +

    Claim List

    +
    + +
    +
    + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + +
    StatusClaim numberTPA IDEmp nameInsured NameCorporate nameTAT
    + +
    +
    +
    +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/app/Views/ticket_mail_template.php b/app/Views/ticket_mail_template.php new file mode 100644 index 00000000..f48b20d2 --- /dev/null +++ b/app/Views/ticket_mail_template.php @@ -0,0 +1,174 @@ + + +
    +
    +
    +
    +
    +

    Mail Template List

    +
    + +
    +
    + + + + + + + + + + + $row){ ?> + + + + + + + + +
    Template NameStatusPolicy Type
    + +
    +
    +
    +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/app/Views/ticket_note.php b/app/Views/ticket_note.php new file mode 100644 index 00000000..7839c63c --- /dev/null +++ b/app/Views/ticket_note.php @@ -0,0 +1,62 @@ +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + \ No newline at end of file diff --git a/app/Views/ticket_reply.php b/app/Views/ticket_reply.php new file mode 100644 index 00000000..0b719e33 --- /dev/null +++ b/app/Views/ticket_reply.php @@ -0,0 +1,67 @@ +
    +
    +
    +
    +
    +
    + +
    + + +
    + + +
    + + +
    + + +
    + + +
    +
    +
    + + +
    + +
    +
    +
    +
    +
    + + diff --git a/app/Views/ticket_search.php b/app/Views/ticket_search.php new file mode 100644 index 00000000..24317d79 --- /dev/null +++ b/app/Views/ticket_search.php @@ -0,0 +1,170 @@ + + +
    +
    +
    +
    +
    + + + +
    +
    +
    +
    +
    + + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + + + +
    + +
    +
    +
    +
    + +
    +
    +
    + + +
    + +
    + + + \ No newline at end of file