FEAT_VIEW_DEMOGRAPHY : RV

This commit is contained in:
VENKATESHWARAN 2025-08-13 17:00:27 +05:30
parent a0630d9468
commit 2008919454
2 changed files with 97 additions and 3 deletions

View File

@ -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 .= "<h3 style='color: #333; font-weight: 500; margin-bottom: 15px;'>{$category}</h3>";
$html .= "<table style='width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px;'>";
// Table header with light background
$html .= "<tr>";
$html .= "<th style='background-color: #f8f9fa; color: #495057; padding: 6px 8px; text-align: left; border: 1px solid #dee2e6; font-weight: 500;'>Relation</th>";
foreach ($allColumns as $col) {
$html .= "<th style='background-color: #f8f9fa; color: #495057; padding: 6px 8px; text-align: center; border: 1px solid #dee2e6; font-weight: 500;'>{$col}</th>";
}
$html .= "</tr>";
// Table rows with clean styling
foreach ($records as $relation => $ages) {
$html .= "<tr>";
$html .= "<td style='padding: 5px 8px; border: 1px solid #dee2e6; background-color: #fff;'>{$relation}</td>";
foreach ($allColumns as $col) {
$value = isset($ages[$col]) ? $ages[$col] : "-";
$html .= "<td style='padding: 5px 8px; border: 1px solid #dee2e6; text-align: center; background-color: #fff;'>{$value}</td>";
}
$html .= "</tr>";
}
$html .= "</table>";
}
}
return $html;
}
}

View File

@ -258,6 +258,11 @@
opacity: 1;
}
.demographyTable .table th,
.demographyTable .table td {
padding: 4px 4px !important;
}
</style>
<div class="row" id="inception_list">
@ -288,6 +293,7 @@
onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>
<?php } ?>
<button id="submitPlacement" class="btn btn-primary" onclick="checkTheTableDataChanged(6)">Placement</button>
<button id="viewDemography" class="btn btn-primary" onclick="viewDemography()">view Demography</button>
<input type="hidden" id="lead_id" name="lead_id" value="<?= isset($lead_id) ? $lead_id : '' ?>">
<input type="hidden" id="rfq_primaryKey" name="rfq_primaryKey" value="<?= isset($rfq_data['id']) ? $rfq_data['id'] : '' ?>">
<input type="hidden" id="qcr_count" value="<?= isset($qcr_count) ? $qcr_count : 0 ?>">
@ -685,6 +691,30 @@
</div>
</div><!-- /.modal -->
<!-- Modal content for View Demography Mail -->
<div class="modal fade" id="view_demography_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="false">
<div class="modal-dialog modal-full-width">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="demographyCenterModalLabel">Demography</h4>
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div style='max-height: 400px; overflow-y: auto; margin-bottom: 30px;'>
<?php
if(isset($demogrphy_html_data) && !empty($demogrphy_html_data)){
echo $demogrphy_html_data;
}else{
echo "<p style='text-align: center; color: #6c757d; font-style: italic;'>No Demography Data Found</p>";
}
?>
</div>
</div>
</div><!-- /.modal-content -->
</div>
</div><!-- /.modal -->
<script>
var isFormDataModified = false;
@ -6711,6 +6741,12 @@ function appendMultiFileData(data) {
});
}, 2000)
})
function viewDemography(){
// Show the modal
const myModal = new bootstrap.Modal(document.getElementById('view_demography_modal'));
myModal.show();
}
</script>