nhance/app/Views/view_policy_terms.php

226 lines
6.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- <br>
<p style="color:black;">
<b>Policy Terms</b>
</p>
<br>
<?php
// // ✅ Format keys: underscores to spaces, each word capitalized
// function readable_key($key) {
// $key = str_replace('_', ' ', $key);
// return ucwords($key);
// }
// // ✅ Format values: 0 = NO, 1 = YES, >1 = number as-is
// function format_value($value) {
// if (is_numeric($value)) {
// if ($value == 0) return 'No';
// if ($value == 1) return 'Yes';
// }
// return $value;
// }
// // ✅ Recursively render nested keyvalue pairs
// function nestedKeyValuePair($data) {
// $output = '';
// foreach ($data as $key => $value) {
// $label = readable_key($key);
// $output .= "<span style='color:black;'> : <b>$label</b>";
// if (is_array($value)) {
// $output .= "<span style='margin-left: 10px;'>" . nestedKeyValuePair($value) . "</span>";
// } else {
// $formattedValue = format_value($value);
// $output .= " : " . htmlspecialchars($formattedValue) ;
// }
// $output .= "</span>";
// }
// return $output;
// }
// if (isset($policy_terms['policy_terms']) && is_array($policy_terms['policy_terms'])) {
// // ✅ Merge multiple_sum_insured with sum_insured
// if (
// isset($policy_terms['policy_terms']['multiple_sum_insured']) &&
// is_array($policy_terms['policy_terms']['multiple_sum_insured'])
// ) {
// $sum_insured_values = implode(' , ', $policy_terms['policy_terms']['multiple_sum_insured']);
// $original_sum = isset($policy_terms['policy_terms']['sum_insured'])
// ? $policy_terms['policy_terms']['sum_insured']
// : '';
// $policy_terms['policy_terms']['sum_insured'] = $original_sum . " , " . $sum_insured_values;
// unset($policy_terms['policy_terms']['multiple_sum_insured']);
// }
// // ✅ Display each policy term
// foreach ($policy_terms['policy_terms'] as $key => $value) {
// if ($key === "age_ratio" || $key === "enrollment_display_key") {
// continue; // Skip excluded keys
// }
// // Normalize specific raw keys (if needed)
// if ($key === 'waiverof30dayswaitingperiod') {
// $key = 'Waiver_of_30_days_waiting_period';
// }
// if ($key === 'suminsuredenhancement') {
// $key = 'sum_insured_enhancement';
// }
// // Readable label
// $label = readable_key($key);
// $nesetedValues = "";
// ?>
// <div class="row">
// <div class="form-group col-3">
// <p style="color:black;"><b><?php //echo htmlspecialchars($label); ?>:</b></p>
// </div>
// <div class="form-group col-6">
// <?php
// if (is_array($value)) {
// $nesetedValues .= nestedKeyValuePair($value) .",";
// echo "$nesetedValues";
// } else {
// $formattedValue = format_value($value);
// echo "<p style='color:black;'>: " . htmlspecialchars($formattedValue) . "</p>";
// }
// ?>
// </div>
// </div>
// <?php
// }
// }
?> -->
<style>
.policy-row {
display: flex;
border-bottom: 1px solid #eee;
padding: 12px 0;
align-items: center;
background-color: #F4FFFF;
border:1px solid #A0F0FF;
border-radius: 10px;
margin-bottom: 10px;
padding-left: 40px;
}
.policy-row:last-child {
border-bottom: none;
}
.policy-label {
flex: 0 0 40%;
padding-right: 20px;
}
.policy-label label {
font-weight: 600;
color: #333;
font-size: 14px;
margin: 0;
text-transform: capitalize;
}
.policy-value {
flex: 1;
padding-left: 20px;
border-left: 1px solid #eee;
}
.policy-value span {
color: #555;
font-size: 14px;
line-height: 1.4;
}
.no-terms-container {
border: 1px solid #ddd;
border-radius: 8px;
background-color: #f9f9f9;
padding: 40px;
text-align: center;
max-width: 800px;
margin: 20px auto;
}
.no-terms-message span {
color: #666;
font-size: 16px;
font-style: italic;
}
/* Responsive design */
@media (max-width: 768px) {
.policy-row {
flex-direction: column;
align-items: flex-start;
}
.policy-label {
flex: none;
padding-right: 0;
padding-bottom: 8px;
width: 100%;
}
.policy-value {
flex: none;
padding-left: 0;
border-left: none;
border-top: 1px solid #eee;
padding-top: 8px;
width: 100%;
}
.key-value-pair{
border:2px solid white !important;
background-color: white !important;
color: black !important;
padding: 5px !important;
}
}
</style>
<?php if(isset($policy_terms)) { ?>
<div class="policy-terms-container">
<?php foreach($policy_terms as $key => $value){ ?>
<div class="policy-row">
<div class="policy-label">
<label><?= htmlspecialchars($key) ?></label>
</div>
<div class="policy-value d-flex flex-wrap">
<?php
if(str_contains($value,":")){
$value_array = explode(",", $value);
foreach($value_array as $val){
echo "<span style='border:2px solid #C3EDEE; border-radius:10px;background-color:white;padding:0 10px 0 10px; margin:10px;'>".
$val .
"</span> &nbsp;&nbsp;";
}
}else{ ?>
<span><?= $value ?></span>
<?php }
?>
</div>
</div>
<?php } ?>
</div>
<?php } else { ?>
<div class="no-terms-container">
<div class="no-terms-message">
<span>No Terms Found</span>
</div>
</div>
<?php } ?>