From 2008919454e346cd589f1b66f1547d40c9214c62 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 13 Aug 2025 17:00:27 +0530 Subject: [PATCH] FEAT_VIEW_DEMOGRAPHY : RV --- app/Controllers/LeadsController.php | 64 +++++++++++++++++++++++++++-- app/Views/view_rfq.php | 36 ++++++++++++++++ 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 9d7a4b2f..2daa6305 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -773,7 +773,7 @@ class LeadsController extends BaseController // dd($data); if ($data['lead_data']['lead_form_type'] == 1) { - + $data['demogrphy_html_data'] = $this->generateDemographyDataTable(['lead_id' => $id]); $this->loadLayout('view_rfq.php', $data); } else if ($data['lead_data']['lead_form_type'] == 2) { @@ -1271,7 +1271,6 @@ class LeadsController extends BaseController return $newRowData; } - private function renumberProposalKeys(array $input): array { $result = []; @@ -2062,7 +2061,7 @@ class LeadsController extends BaseController return true; } - public function calculateMembersDemography($params) + public function calculateMembersDemography($params, $returnType = null) { $lead_id = $params['lead_id']; $lead_data = $this->leadsModel->find($lead_id); @@ -2115,12 +2114,20 @@ class LeadsController extends BaseController $this->myLogger->logme('error', ($message . $file_name_with_path)); return ['status' => 'failed', 'message' => $message]; } + try { $classifiers = $this->getDemographyData($members, $age_band_data, $members_heading, $available_col, $col_index); } catch (Exception $e) { return ['status' => 'fail', 'message' => $e->getMessage()]; } + //for this to view the demography in the RFQ and QCR page to using internal + if($returnType == "internal"){ + return ['data' => $classifiers]; + // print_rr($classifiers); die; + } + + try { $result = $this->generateClassifierSpreadsheet($classifiers, WRITEPATH . 'uploads/lead_files/'); if ($result['success']) { @@ -4818,4 +4825,55 @@ class LeadsController extends BaseController return []; } + + + public function generateDemographyDataTable($param) + { + $returnData = $this->calculateMembersDemography($param, "internal"); + + $html = ""; + + if (isset($returnData['data'])) { + + $data = $returnData['data']; + foreach ($data as $category => $records) { + // Extract all column headers (age groups) dynamically + $allColumns = []; + foreach ($records as $person => $ages) { + $allColumns = array_merge($allColumns, array_keys($ages)); + } + $allColumns = array_unique($allColumns); + $allColumns = array_values($allColumns); // reset index + + $category = ucfirst($category); + + // Start table with clean styling + $html .= "

{$category}

"; + $html .= ""; + + // Table header with light background + $html .= ""; + $html .= ""; + foreach ($allColumns as $col) { + $html .= ""; + } + $html .= ""; + + // Table rows with clean styling + foreach ($records as $relation => $ages) { + $html .= ""; + $html .= ""; + foreach ($allColumns as $col) { + $value = isset($ages[$col]) ? $ages[$col] : "-"; + $html .= ""; + } + $html .= ""; + } + + $html .= "
Relation{$col}
{$relation}{$value}
"; + } + } + + return $html; + } } diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index b6ed108b..f00350cb 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -258,6 +258,11 @@ opacity: 1; } + .demographyTable .table th, + .demographyTable .table td { + padding: 4px 4px !important; + } +
@@ -288,6 +293,7 @@ onclick="checkTheTableDataChanged(3)">Send Insurer Mail + @@ -685,6 +691,30 @@
+ + +