diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php
index 2fda3d14..80e71ec9 100644
--- a/app/Controllers/BDSReportController.php
+++ b/app/Controllers/BDSReportController.php
@@ -46,16 +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,
@@ -64,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,
@@ -93,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
@@ -102,20 +100,20 @@ 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()
{
- 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');
@@ -141,24 +139,30 @@ class BDSReportController extends AdminController
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);
-
+ 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);
} else if($report_type == 'bapInsurer'){
@@ -332,7 +336,6 @@ class BDSReportController extends AdminController
$this->myLogger->logme('error', 'Query executed successfully.');
// dd(db_connect()->getLastQuery(),$result);
return $result;
-
} catch (\Exception $e) {
// Log the exception details for debugging
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 @@
+
-
-
-
+
-
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 @@
+