Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-05-13 18:49:14 +05:30
commit a2ef928de8
11 changed files with 963 additions and 201 deletions

View File

@ -1383,11 +1383,11 @@ class EmployeeServiceController extends AdminController
{
// dd($employee);
$existing_endorsements = $this->empEndorsementModel->where('actions','d')
->where('table_name','employees')
->where('table_name','employee_polices')
->where('endorsement_id is null')
->where('emp_code',$employee['emp_code'])
->where('name',$employee['name'])
->where('field_name','emp_status')
->where('field_name','status')
->where('status !=','truncated')
->where('is_active', 1)
->findAll();
@ -2087,12 +2087,14 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$relation = 'parent';
} else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
$relation = 'child';
}else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){
}else if((strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law') || (strtolower(trim($value['relationship'])) === 'father-in-law' || strtolower(trim($value['relationship'])) === 'mother-in-law')){
$relation = 'parent_in_law';
}else if(strtolower(trim($value['relationship'])) === 'spouse'){
$relation = 'spouse';
}else{
}else if(strtolower(trim($value['relationship'])) === 'self'){
$relation = 'self';
}else {
$relation = '';
}
$value['family_floater_key'] = $relation;

View File

@ -2378,7 +2378,9 @@ class LeadsController extends BaseController
$installment_data = json_decode($params['installments'], true);
if(!empty($installment_data)){
foreach ($installment_data as $key => $value) {
$value['payment_date'] = date('Y/m/d', strtotime($value['payment_date'])) ?? null;
$value['payment_date'] = !empty($value['payment_date']) && strtotime($value['payment_date'])
? date('Y/m/d', strtotime($value['payment_date']))
: null;
if(isset($value['id']) && !empty($value['id'])){
$this->leadInstallmentPaymentDetails->where('id', $value['id'])->set($value)->update();
}else{

View File

@ -198,6 +198,12 @@ class TicketController extends BaseController
}else if ($isFromDashboard == 2){
$data['ticket_data'] = $this->ticketSearch(4);
}else if ($isFromDashboard == 3){
$data['ticket_data'] = $this->ticketSearch(2);
}else if ($isFromDashboard == 4){
$data['ticket_data'] = $this->ticketSearch(5);
}
$data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll();
$data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active', 1)->findAll();
@ -249,7 +255,7 @@ class TicketController extends BaseController
->groupBy('tm.id, tm.created_at, latest_history.created_at');
//action 1 get last 100 rows, action 2 filter and get all rows related to that, action 3 gets according to dashboard, action 4 gets according to ACM
//action 1 get last 100 rows, action 2 filter and get all rows related to that, action 3 gets according to dashboard, action 4 gets according to ACM, action 5 tat
if ($action == 1) {
$query = $db->table('ticket_master tm')
@ -356,6 +362,10 @@ class TicketController extends BaseController
$where = '1 = 0'; // No valid IDs, return empty result
}
}else if ($action == 5) {
$search_data = $this->request->getPost();
$where = "tm.created_at >= '" . $search_data['from_date'] . "' AND tm.created_at <= '" . $search_data['to_date'] . "'" ."and ticket_type_id = ".$search_data['ticket_type_id'];
} else {
$search_data = $this->request->getPost();
// print_r($search_data); die()
@ -445,6 +455,17 @@ class TicketController extends BaseController
->orderBy('tm.id', 'DESC');
$data = $query->get()->getResultArray();
// dd($db->getLastQuery()->getQuery());
// dd($data);
if ($action == 5){
$tat = $this->request->getPost("tat_category");
$data = array_values(array_filter($data, function($dat) use ($tat) {
return $dat['tat'] == $tat;
}));
}
// print_rr($data);
// log_message('error',' Claims Master Data '.json_encode($data));die();
// print_rr($data);die();
@ -1068,6 +1089,10 @@ class TicketController extends BaseController
$this->myLogger->logme('error', "Replacing placeholders in content");
if (!empty($ticket_data) && !empty($content)) {
// print_rr($ticket_data);die();
if (!isset($ticket_data['id'])) { $ticket_data['id'] = $ticket_data['ticket_master_id'];}
if (!isset($ticket_data['ticket_master_id'])) {$ticket_data['ticket_master_id'] = $ticket_data['id'];}
foreach ($this->placeHolders as $key => $value) {
if ($value == "emp_code") {
@ -1451,7 +1476,7 @@ class TicketController extends BaseController
'TPA_NAME', 'NON ID', 'ID NOT GENERATED', 'CDA', 'INFORMATION REQUIRED',
'UNDER PROCESS - CLAIM NO. UPDATION',
'UNDER PROCESS - QUERY DOCUMENT RECEIVED', 'APPROVED', 'PAYMENT INITIATED',
'TOTAL', 'SETTLED', 'CLOSED', 'CANCELLED', 'RETURNED', 'CLEARED_TOTAL'
'TOTAL', 'SETTLED', 'CLOSED', 'CANCELLED', 'RETURNED', 'CLEARED_TOTAL','TPA_ID'
];
// Reorder data based on column order
@ -1465,6 +1490,7 @@ class TicketController extends BaseController
$ordered_data[] = $temp;
}
$viewData['tpa_wise_data'] = $ordered_data;
// print_r($ordered_data);die();
// $html = view('claims_report_tpa_wise', $viewData);
$html = view('claims_report_tpa_wise',$viewData);
@ -1472,6 +1498,9 @@ class TicketController extends BaseController
} else if ($received_data['report_type'] == 'tat_band_wise') {
$viewData['data'] = $this->ticketMasterModel->getTATReport($policy_type, $fromDate, $toDate);
$viewData['policyType'] = $policy_type;
$viewData['fromDate'] = $fromDate;
$viewData['toDate'] = $toDate;
$html = view('tat_report_band_wise_list', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200);
}
@ -1876,9 +1905,10 @@ class TicketController extends BaseController
}
}
private function isDate($value) {
private function isDate($value, $format = 'Y-m-d') {
// Check if the value is a valid date string (basic validation)
return strtotime($value) !== false;
$date = \DateTime::createFromFormat($format, $value);
return $date && $date->format($format) === $value;
}

View File

@ -2210,12 +2210,14 @@ if (!function_exists('generate_family_floater_key')) {
$relation = 'parent';
} else if (strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter') {
$relation = 'child';
} else if (strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') {
}else if((strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') || (strtolower(trim($relationship)) === 'father-in-Law' || strtolower(trim($relationship)) === 'mother-in-Law')){
$relation = 'parent_in_law';
} else if (strtolower(trim($relationship)) === 'spouse') {
$relation = 'spouse';
} else {
} else if(strtolower(trim($relationship)) === 'self'){
$relation = 'self';
}else{
$relation = '';
}
return $relation;

View File

@ -335,159 +335,240 @@ class TicketMasterModel extends Model
// return $data;
// }
// public function getTATReport($ticket_type = null, $start_date = null, $end_date = null)
// {
// //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 = change_date_format($start_date);
// $toDate = change_date_format($end_date);
// }
// $ticket_type_data_1 = "";
// $ticket_type_data_2 = "";
// if (!empty($ticket_type)) {
// $ticket_type_data_1 = "AND ticket_type = $ticket_type";
// $ticket_type_data_2 = "WHERE tm.ticket_type_id = $ticket_type";
// }
// // Fetch claim statuses from the `ticket_claim_status` table
// $statusQuery = " SELECT
// id, claim_status, ticket_type
// FROM ticket_claim_status
// Where is_active = 1
// $ticket_type_data_1
// ";
// $statusResult = $this->db->query($statusQuery)->getResultArray();
// // dd($statusResult);
// // Initialize dynamic query parts
// $dynamicSelect = '';
// // Loop through each claim status and generate the COALESCE and CASE statements for the SELECT
// foreach ($statusResult as $status) {
// $columnName = $status['claim_status']; // Default column name
// if (empty($ticket_type)) {
// // Append the insurance type prefix based on `ticket_type`
// switch ($status['ticket_type']) {
// case 1:
// $columnName = "GMC - {$status['claim_status']}";
// break;
// case 2:
// $columnName = "GPA - {$status['claim_status']}";
// break;
// case 3:
// $columnName = "EDLI - {$status['claim_status']}";
// break;
// case 4:
// $columnName = "GTLI - {$status['claim_status']}";
// break;
// }
// }
// $dynamicSelect .= "
// COALESCE(
// SUM(
// CASE
// WHEN subquery.status_id = {$status['id']} THEN 1
// ELSE 0
// END
// ),
// 0
// ) AS `$columnName`, ";
// }
// // Remove the trailing comma from the SELECT part
// $dynamicSelect = rtrim($dynamicSelect, ', ');
// // dd($dynamicSelect);
// // Construct the full SQL query
// $sql = "
// SELECT
// tc.TAT_Category,
// $dynamicSelect
// FROM
// (
// SELECT 'Above 20 Days' AS TAT_Category
// UNION ALL
// SELECT '13-20 Days'
// UNION ALL
// SELECT '7-12 Days'
// UNION ALL
// SELECT '0-6 Days'
// ) AS tc
// LEFT JOIN (
// SELECT
// tm.id AS ticket_id,
// latest_status.claim_status_id AS status_id,
// CASE
// WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 0 AND 6 THEN '0-6 Days'
// WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 7 AND 12 THEN '7-12 Days'
// WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 13 AND 20 THEN '13-20 Days'
// ELSE 'Above 20 Days'
// END AS TAT_Category
// FROM
// ticket_master tm
// LEFT JOIN (
// SELECT
// th.ticket_id,
// th.new_value AS claim_status_id,
// MAX(th.created_at) AS change_date
// FROM
// ticket_history th
// WHERE
// th.field_name = 'claim_status_id'
// AND th.is_active = 1
// GROUP BY
// th.ticket_id, th.new_value
// ) AS latest_status ON latest_status.ticket_id = tm.id
// WHERE tm.is_active = 1
// AND tm.created_at >= '$fromDate'
// AND tm.created_at <= '$toDate'
// " . (!empty($ticket_type) ? " AND tm.ticket_type_id = $ticket_type" : "") . "
// GROUP BY tm.id, latest_status.claim_status_id, latest_status.change_date, tm.created_at
// ) AS subquery ON tc.TAT_Category = subquery.TAT_Category
// GROUP BY
// tc.TAT_Category
// ORDER BY
// FIELD(
// tc.TAT_Category,
// 'Above 20 Days',
// '13-20 Days',
// '7-12 Days',
// '0-6 Days'
// );
// ";
// // Execute the query and return the result
// $data = $this->db->query($sql)->getResultArray();
// // dd($data);
// print_rr($data);die();
// // print_rr($this->db->getLastQuery()->getQuery()); die;
// return $data;
// }
public function getTATReport($ticket_type = null, $start_date = null, $end_date = null)
{
//set default last 3 months data date
// Set default date range (last 90 days)
$fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59');
if (!empty($start_date) && !empty($end_date)) {
$fromDate = change_date_format($start_date);
$toDate = change_date_format($end_date);
}
$ticket_type_data_1 = "";
$ticket_type_data_2 = "";
// Get all active claim statuses
$statusQuery = $this->db->table('ticket_claim_status')
->select('id, claim_status')
->where('is_active', 1)
->orderBy('id', 'ASC');
if (!empty($ticket_type)) {
$ticket_type_data_1 = "AND ticket_type = $ticket_type";
$ticket_type_data_2 = "WHERE tm.ticket_type_id = $ticket_type";
$statusQuery->where('ticket_type', $ticket_type);
}
// Fetch claim statuses from the `ticket_claim_status` table
$statusQuery = " SELECT
id, claim_status, ticket_type
FROM ticket_claim_status
Where is_active = 1
$ticket_type_data_1
";
$statusResult = $this->db->query($statusQuery)->getResultArray();
// dd($statusResult);
// Initialize dynamic query parts
$dynamicSelect = '';
// Loop through each claim status and generate the COALESCE and CASE statements for the SELECT
foreach ($statusResult as $status) {
$columnName = $status['claim_status']; // Default column name
if (empty($ticket_type)) {
// Append the insurance type prefix based on `ticket_type`
switch ($status['ticket_type']) {
case 1:
$columnName = "GMC - {$status['claim_status']}";
break;
case 2:
$columnName = "GPA - {$status['claim_status']}";
break;
case 3:
$columnName = "EDLI - {$status['claim_status']}";
break;
case 4:
$columnName = "GTLI - {$status['claim_status']}";
break;
$statusResult = $statusQuery->get()->getResultArray();
// Create a list of all TAT categories we want in the output
$tatCategories = [
'Above 20 Days',
'13-20 Days',
'7-12 Days',
'0-6 Days'
];
// Initialize the result array with all TAT categories
$result = [];
foreach ($tatCategories as $category) {
$row = ['TAT_Category' => $category];
foreach ($statusResult as $status) {
$row[$status['claim_status']] = 0;
}
$result[] = $row;
}
// Get the base query for ticket counts by status and TAT category
$query = $this->db->table('ticket_master tm')
->select([
'tcs.claim_status',
'CASE
WHEN DATEDIFF(CURDATE(), COALESCE(
(SELECT MAX(th.created_at)
FROM ticket_history th
WHERE th.ticket_id = tm.id
AND th.field_name = "claim_status_id"
AND th.is_active = 1),
tm.created_at
)) BETWEEN 0 AND 6 THEN "0-6 Days"
WHEN DATEDIFF(CURDATE(), COALESCE(
(SELECT MAX(th.created_at)
FROM ticket_history th
WHERE th.ticket_id = tm.id
AND th.field_name = "claim_status_id"
AND th.is_active = 1),
tm.created_at
)) BETWEEN 7 AND 12 THEN "7-12 Days"
WHEN DATEDIFF(CURDATE(), COALESCE(
(SELECT MAX(th.created_at)
FROM ticket_history th
WHERE th.ticket_id = tm.id
AND th.field_name = "claim_status_id"
AND th.is_active = 1),
tm.created_at
)) BETWEEN 13 AND 20 THEN "13-20 Days"
ELSE "Above 20 Days"g
END AS tat_category',
'COUNT(*) AS count'
])
->join('ticket_claim_status tcs', 'tcs.id = tm.claim_status_id AND tcs.is_active = 1')
->where('tm.is_active', 1)
->where('tm.created_at >=', $fromDate)
->where('tm.created_at <=', $toDate)
->groupBy('tcs.claim_status, tat_category')
->orderBy('FIELD(tat_category, "Above 20 Days", "13-20 Days", "7-12 Days", "0-6 Days")');
if (!empty($ticket_type)) {
$query->where('tm.ticket_type_id', $ticket_type);
}
$countResults = $query->get()->getResultArray();
// Populate the result array with actual counts
foreach ($countResults as $row) {
foreach ($result as &$categoryRow) {
if ($categoryRow['TAT_Category'] === $row['tat_category']) {
$categoryRow[$row['claim_status']] = (int)$row['count'];
break;
}
}
$dynamicSelect .= "
COALESCE(
SUM(
CASE
WHEN subquery.status_id = {$status['id']} THEN 1
ELSE 0
END
),
0
) AS `$columnName`, ";
}
// Remove the trailing comma from the SELECT part
$dynamicSelect = rtrim($dynamicSelect, ', ');
// dd($dynamicSelect);
// Construct the full SQL query
$sql = "
SELECT
tc.TAT_Category,
$dynamicSelect
FROM
(
SELECT 'Above 20 Days' AS TAT_Category
UNION ALL
SELECT '13-20 Days'
UNION ALL
SELECT '7-12 Days'
UNION ALL
SELECT '0-6 Days'
) AS tc
LEFT JOIN (
SELECT
th.ticket_id,
tcs.claim_status,
tcs.id AS status_id,
CASE
WHEN DATEDIFF(
th.created_at,
COALESCE(
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
tm.created_at
)
) BETWEEN 0 AND 6 THEN '0-6 Days'
WHEN DATEDIFF(
th.created_at,
COALESCE(
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
tm.created_at
)
) BETWEEN 7 AND 12 THEN '7-12 Days'
WHEN DATEDIFF(
th.created_at,
COALESCE(
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
tm.created_at
)
) BETWEEN 13 AND 20 THEN '13-20 Days'
ELSE 'Above 20 Days'
END AS TAT_Category
FROM
ticket_master tm
JOIN ticket_history th ON tm.id = th.ticket_id
JOIN ticket_claim_status tcs ON th.field_name = 'claim_status_id' AND th.new_value = tcs.id
$ticket_type_data_2
AND tm.created_at >= '$fromDate'
AND tm.created_at <= '$toDate'
AND tm.is_active = 1
AND th.is_active = 1
AND tcs.is_active = 1
) AS subquery ON tc.TAT_Category = subquery.TAT_Category
GROUP BY
tc.TAT_Category
ORDER BY
FIELD(
tc.TAT_Category,
'Above 20 Days',
'13-20 Days',
'7-12 Days',
'0-6 Days'
);
";
// Execute the query and return the result
$data = $this->db->query($sql)->getResultArray();
// print_rr($this->db->getLastQuery(), $data); die;
// $tableData = [];
// if (!empty($data)) {
// // Extract table headers from the first row keys
// $headers = array_keys($data[0]);
// $tableData['headers'] = $headers;
// $tableData['body'] = $data;
// }
return $data;
return $result;
}
public function tpaWiseReport($policy_type = null, $start_date = null, $end_date = null)
@ -544,6 +625,7 @@ class TicketMasterModel extends Model
// Construct the final SQL query
$sql = "
SELECT
tpa.id as TPA_ID,
tpa.name AS TPA_NAME,
$dynamicSelect,
($dynamicTotal) AS TOTAL,

View File

@ -37,16 +37,18 @@
</tr>
<tr>
<?php foreach ($column_order as $col_name): ?>
<th><?= str_replace('_', ' ', $col_name) ?></th>
<?php endforeach; ?>
<?php if ($col_name != "TPA_ID") { ?>
<th><?= str_replace('_', ' ', $col_name) ?></th>
<?php } endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($tpa_wise_data as $row): ?>
<tr>
<?php foreach ($column_order as $col_name): ?>
<td><?= $row[$col_name] ?></td>
<?php endforeach; ?>
<?php if ($col_name != "TPA_ID") { ?>
<td onclick="redirectTPAToClaimList(<?= $row['TPA_ID'] ?>)"><?= $row[$col_name] ?></td>
<?php } endforeach;?>
</tr>
<?php endforeach; ?>
</tbody>
@ -62,7 +64,7 @@
}
foreach ($column_order as $col_name) {
if ($col_name !== 'TPA_NAME') {
if ($col_name !== 'TPA_NAME' && $col_name != "TPA_ID") {
echo "<th>{$totals[$col_name]}</th>";
}
}
@ -98,4 +100,35 @@
console.error("Table not found.");
}
});
</script>
function redirectTPAToClaimList(tpa_id){
// alert(tpa_id);
data = {
'tpa_id' : tpa_id,
'is_dashboard':3
}
redirectWithPost("<?= base_url("ticket/list") ?>", data);
}
function redirectWithPost(url, data = {}) {
const form = document.createElement('form');
form.method = 'POST';
form.action = url;
for (const key in data) {
if (data.hasOwnProperty(key)) {
const input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = data[key];
form.appendChild(input);
}
}
document.body.appendChild(form);
form.submit();
}
</script>

View File

@ -465,9 +465,19 @@ if (isset($selected_lead_type)) {
<script>
$(document).ready(async function () {
handleEbAndNonEbEdit(
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>
);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
setTimeout(() => {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
handleEbAndNonEbEdit(
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>
);
}, 1000);
});
function handleEbAndNonEbEdit(data){

View File

@ -1144,15 +1144,21 @@
function registerPolicyData() {
var policyType;
var policyAcronym;
if (totalSI < 50000000) {
if (totalSI <= 50000000) {
policyType = "Bharat Sookshma Udyam Suraksha (BSUS)"
} else if (totalSI > 50000000 && totalSI < 500000000) {
policyAcronym = "bsu"
} else if (totalSI > 50000000 && totalSI <= 500000000) {
policyType = "Bharat Laghu Udyam Suraksha (BLUS)"
policyAcronym = "blu"
} else if (totalSI > 500000000) {
policyType = "Standard Fire and Special Perils (SFSP)";
policyAcronym = "sfsp"
}
modifyExcessTable(policyAcronym);
// Build the initial JSON object with productSelection and policyDetails
var outputData = {
policyType: policyType,

View File

@ -63,7 +63,7 @@
$rowTotal += $numValue; // Add to row total
}
?>
<td><?= esc($value) ?></td>
<td onclick="redirectTATtoClaims(`<?= $row['TAT_Category'] ?>`,`<?= $policyType ?>`)"><?= esc($value) ?></td>
<?php endforeach; ?>
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Display row total -->
</tr>
@ -129,4 +129,41 @@
});
// ----------------------------------------------------------------------------------------------------
</script>
<script>
function redirectTATtoClaims(tat_category, policyType) {
// Safely render PHP dates inside JavaScript strings
var fromDate = "<?= isset($fromDate) && $fromDate != null ? change_date_format($fromDate) : date('Y-m-d', strtotime('-90 days')) ?>";
var toDate = "<?= isset($toDate) && $toDate != null ? change_date_format($toDate) : date('Y-m-d 23:59:59') ?>";
var data = {
'tat_category': tat_category,
'is_dashboard': 4,
'ticket_type_id': policyType,
'from_date': fromDate,
'to_date': toDate
};
redirectWithPost("<?= base_url("ticket/list") ?>", data);
}
function redirectWithPost(url, data = {}) {
const form = document.createElement('form');
form.method = 'POST';
form.action = url;
for (const key in data) {
if (data.hasOwnProperty(key)) {
const input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = data[key];
form.appendChild(input);
}
}
document.body.appendChild(form);
form.submit();
}
</script>

View File

@ -550,7 +550,7 @@
<hr>
<div id="installment_form_row">
<?= isset($lead_data['installment_data']) && !empty($lead_data['installment_data']) ? $lead_data['installment_data'] : '' ?>
<?= isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1 && isset($lead_data['installment_data']) && !empty($lead_data['installment_data']) ? $lead_data['installment_data'] : '' ?>
</div>
<hr>
@ -5865,27 +5865,92 @@ function appendMultiFileData(data) {
})
$("#is_installment_switch").change(function (){
var switch_status = ($(this).is(":checked")? "on" : "off");
console.log("Switch status",switch_status);
if (switch_status == "on"){
$("#no_of_installment").show();
$("#payment_date").hide();
$("#utr_no").hide();
$("#no_of_installment").closest('.form-group').show();
$("#payment_date").closest('.form-group').hide();
$("#utr_no").closest('.form-group').hide();
addInstallmentHTML()
}else{
$("#no_of_installment").hide();
$("#payment_date").show();
$("#utr_no").show();
$("#no_of_installment").closest('.form-group').hide();
$("#payment_date").closest('.form-group').show();
$("#utr_no").closest('.form-group').show();
$('#installment_form_row').empty();
}
var switch_status = ($(this).is(":checked")? "on" : "off");
console.log("Switch status",switch_status);
if (switch_status == "on"){
$("#no_of_installment").show();
$("#payment_date").hide();
$("#utr_no").hide();
$("#no_of_installment").closest('.form-group').show();
$("#payment_date").closest('.form-group').hide();
$("#utr_no").closest('.form-group').hide();
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
if (row_count == 0 ) { addInstallmentHTML()}
// addInstallmentHTML()
}else{
console.log("inside else")
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
let remove_count = $("#no_of_installment").val();
console.log("row count",row_count);
if (row_count > 0 ) {
let ids = $installmentContainer.find('.form-row').slice(-remove_count).find('input[name="installment_primary_key[]"]').map(function() {
return $(this).val();
}).get();
Swal.fire({
title: "Do you want to remove all the entries?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, Proceed!"
}).then((result) => {
if (result.isConfirmed) {
let url = '<?= base_url('util/removeInstallments') ?>';
let requestData = { id: ids };
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
$("#no_of_installment").hide();
$("#payment_date").show();
$("#utr_no").show();
$("#no_of_installment").closest('.form-group').hide();
$("#payment_date").closest('.form-group').show();
$("#utr_no").closest('.form-group').show();
$('#installment_form_row').empty();
$('#no_of_installment').val("");
} else {
toastr.error(response.message, 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while removing the installment.', 'ERROR');
});
}else{
// alert("Inside else");
$('#no_of_installment').val(row_count);
// $("#is_installment_switch").bootstrapToggle('on');
// $('#is_installment_switch').val('1').change();
// $('#is_installment_switch').bootstrapToggle('on');
// $('#is_installment_switch').prop('checked', true).trigger('change');
$('#is_installment_switch').trigger('click'); // in some cases, this forces the CSS to update
}
});
}
}
})
$(document).on("input", "#cd_amount, #premium_amount", function() {
// alert("Function called");
@ -6028,8 +6093,8 @@ function appendMultiFileData(data) {
console.log("Form row count:", row_count);
if (row_count === 1) {
$installmentContainer.empty();
for (let index = 0; index < no_of_installments; index++) {
// $installmentContainer.empty();
for (let index = 0; index < no_of_installments - 1; index++) {
addInstallmentHTML();
}
} else if (no_of_installments === row_count) {
@ -6047,7 +6112,7 @@ function appendMultiFileData(data) {
console.log('ids', ids);
if (ids != null) {
if (Object.keys(ids).length > 0) {
Swal.fire({
title: "Do you want to remove the last " + (remove_count ?? "") + " entries?",
icon: "warning",
@ -6106,6 +6171,7 @@ function appendMultiFileData(data) {
}
});
$(document).ready(function(){
setTimeout(function(){
$('.payment_date').flatpickr({

View File

@ -255,6 +255,12 @@
cursor: pointer;
user-select: none;
}
.toggle.btn {
height: 38px !important;
line-height: 33px !important;
}
</style>
@ -424,31 +430,66 @@
<div class="form-row">
<div class="form-group col-md-3">
<label for="utr_no">UTR No.</label>
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No." value="<?= isset($lead_data['utr_no']) ? $lead_data['utr_no'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="placement_date">Placement Date</label>
<input type="text" class="form-control" id="placement_date" name="placement_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['placement_date']) ? date('d/m/Y', strtotime($lead_data['placement_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="is_cd_switch">CD Entry</label>
<input id="is_cd_switch" type="checkbox" name = "is_cd" value = "1" data-toggle="toggle" data-on="With CD" data-off="Without CD" data-onstyle="info" data-offstyle="dark" data-style="border" data-width="218" <?= isset($lead_data['is_cd']) && $lead_data['is_cd'] != 1 ? '' : 'checked' ?>>
</div>
<div class="form-group col-md-3">
<label for="premium_amount">Premium Amount</label>
<input type="text" class="form-control" id="premium_amount" name="premium_amount" placeholder="Enter Premium Amount" value="<?= isset($lead_data['premium_amount']) ? $lead_data['premium_amount'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="total_amount">Total Amount</label>
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount" value="<?= isset($lead_data['total_amount']) ? $lead_data['total_amount'] : "" ?>">
</div>
<?php if (isset($lead_data['is_cd']) && $lead_data['is_cd'] == 1 || !isset($lead_data['is_cd'])) { ?>
<div class="form-group col-md-3">
<label for="cd_amount">CD Amount</label>
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="total_amount">Total Amount</label>
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
</div>
<?php } ?>
<div class="form-group col-md-3">
<label for="cd_amount">CD Amount</label>
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
<label for="is_installment_switch">Installemnt </label>
<input id="is_installment_switch" type="checkbox" name = "is_installment" value = "1" data-toggle="toggle" data-on="With Installments" data-off="Without Installments" data-onstyle="info" data-offstyle="dark" data-style="border" data-width="218" style="height: 37.53px;" <?= isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1 ? 'checked' : '' ?>>
</div>
<div class="form-group col-md-3" style="<?= (!empty($lead_data['is_installment']) && $lead_data['is_installment'] == 1) ? 'display: block;' : 'display: none;' ?>">
<label for="no_of_installment">No of Installments</label>
<input type="text" class="form-control" id="no_of_installment" name="no_of_installment"
value="<?= isset($lead_data['no_of_installment']) ? $lead_data['no_of_installment'] : 1 ?>">
</div>
<?php if (isset($lead_data['is_installment']) && $lead_data['is_installment'] == 0 || !isset($lead_data['is_installment'])) { ?>
<div class="form-group col-md-3">
<label for="payment_date">Payment Date</label>
<input type="text" class="form-control" id="payment_date" name="payment_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['payment_date']) ? date('d/m/Y', strtotime($lead_data['payment_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="utr_no">UTR No.</label>
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No." value="<?= isset($lead_data['utr_no']) ? $lead_data['utr_no'] : "" ?>">
</div>
<?php } ?>
</div>
<hr>
<div id="installment_form_row">
<?= isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1 && isset($lead_data['installment_data']) && !empty($lead_data['installment_data']) ? $lead_data['installment_data'] : '' ?>
</div>
<hr>
<div class="form-row">
@ -517,6 +558,22 @@
<script>
const dynamicExcessJson = {
"excess_fire":[
{
"blu":"5% of claim amount subject to minimum of Rs. 10000/- for each and every claim",
"bsu":"5% of claim amount subject to minimum of Rs. 5000/- for each and every claim",
"sfsp":"For location having SI upto INR 10Cr: 5% of claim amount subject to a minimum of Rs.10,000/- for each and every claim. For location having SI above INR 10Cr and upto 100 Cr: 5% of claim amount subject to a minimum of Rs.25,000/- For each and every claim .For location having SI above INR 100Cr and upto 1500 Cr: 5% of claim amount subject to a minimum of Rs.500,000/- for each and every claim"
}
],
"excess_burglary":[
{
"blu":"5% of claim amount subject to minimum of Rs.5,000/-",
"bsu": "5% of claim amount subject to minimum of Rs.2,500/- for Burglary & 5,000/- for Theft each and every claim"
}
]
}
var isSaved = true;
// var randomColor = 'hsl(' + Math.random() * 360 + ', 100%, 93%)';
var rfq_data = <?= isset($rfq_data['json']) ? json_encode($rfq_data['json'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) : '""' ?>;
@ -1828,6 +1885,8 @@
// Add new rows from tableData
tableData.table_row_contents.forEach((rowData, index) => {
let rowID = Object.keys(rowData)[0];
// console.log("rowData: ",rowData);
// alert(rowID.answer_type);
var question = rowData[rowID].display_value;
const row = document.createElement('tr');
@ -1867,15 +1926,20 @@
// Check if subheader is NOT "Sum Insured"
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" && !subHeaderText.startsWith("Liability Limit")?
"insurer_proposal" : ""; // alert(subHeaderText);
// console.log("default_answers_array",default_answers_array)
let default_answers_array = rowData[rowID].default_answer
let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
let defaul_value = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
let default_answer = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
// // // console.log("defaultJsonString", defaultJsonString);
// // // console.log("defaultJsonString type", typeof defaultJsonString);
// // // console.log("defaultJsonString string", String(defaultJsonString));
// console.log("defaultJsonString", defaultJsonString);
// console.log("defaultJsonString type", typeof defaultJsonString);
// console.log("defaultJsonString string", String(defaultJsonString));
return `<td class="${className}" onblur="setValueForHiddenField(this,'${rowID.answer_type}')"
return `<td class="${className}" onblur="setValueForHiddenField(this,'${rowData[rowID].answer_type}')"
onclick="getAnswer('${'excess'}','${rowID}')"
contenteditable="true">
@ -4767,6 +4831,7 @@
var lead_id = $('#lead_id').val();
let to = $('#placement_to').val();
let placement_date = $('#placement_date').val();
let payment_date = $('#payment_date').val();
let utr_no = $('#utr_no').val();
let premium_amount = $('#premium_amount').val();
let total_amount = $('#total_amount').val();
@ -4776,6 +4841,10 @@
let proposal_insurer = $('#proposals option:selected').data('id');
let insurer_and_branch = $('#proposals').val();
let cc = $('#placement_cc').val();
let is_cd = $("#is_cd_switch").is(":checked") ? 1 : 0;
let no_of_installment = $('#no_of_installment').val();
let is_installment = $("#is_installment_switch").is(":checked") ? 1 : 0;
// Process `to` field
to = to.split(',').map(email => email.trim());
@ -4787,6 +4856,33 @@
selectedFiles.push($(this).val());
});
let data = [];
$('#installment_form_row .form-row').each(function () {
var lead_id = $('#lead_id').val();
let installment_amount = $(this).find('input[name="installment_amount[]"]').val();
let payment_date = $(this).find('input[name="payment_date[]"]').val();
let utr_no = $(this).find('input[name="utr_no[]"]').val();
let id = $(this).find('input[name="installment_primary_key[]"]').val();
console.log('installment_primary_key', id);
let obj = {
lead_id: lead_id,
installment_amount: installment_amount,
payment_date: payment_date,
utr_no: utr_no
};
if (id != undefined && id != null && id != '') {
obj.id = id;
}
data.push(obj);
});
// Prepare FormData
var formData = new FormData();
@ -4799,12 +4895,17 @@
formData.append('proposal_insurer', proposal_insurer);
formData.append('insurer_and_branch', insurer_and_branch);
formData.append('placement_date', placement_date);
formData.append('payment_date', payment_date);
formData.append("is_cd",is_cd);
formData.append('utr_no', utr_no);
formData.append('premium_amount', premium_amount);
formData.append('total_amount', total_amount);
formData.append('cd_amount', cd_amount);
formData.append('mail_content', mail_content);
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
formData.append('installments', JSON.stringify(data));
formData.append('no_of_installment', no_of_installment);
formData.append('is_installment', is_installment);
ajaxRequest(formData);
@ -5180,5 +5281,396 @@
return false;
}
$(document).on("input", "#cd_amount, #premium_amount", function() {
// alert("Function called");
var cd_amount = parseInt($("#cd_amount").val()) || 0;
var premium_amount = parseInt($("#premium_amount").val()) || 0;
var total_amount = (cd_amount + premium_amount);
$("#total_amount").val(total_amount);
});
$("#is_cd_switch").change(function (){
var switch_status = ($("#is_cd_switch").is(":checked")? "on" : "off");
console.log("Switch status",switch_status);
if (switch_status == "on"){
$("#cd_amount").show();
$("#total_amount").show();
$("#cd_amount").closest('.form-group').show();
$("#total_amount").closest('.form-group').show();
}else{
$("#cd_amount").hide();
$("#total_amount").hide();
$("#cd_amount").closest('.form-group').hide();
$("#total_amount").closest('.form-group').hide();
}
})
$("#is_installment_switch").change(function (){
var switch_status = ($(this).is(":checked")? "on" : "off");
console.log("Switch status",switch_status);
if (switch_status == "on"){
$("#no_of_installment").show();
$("#payment_date").hide();
$("#utr_no").hide();
$("#no_of_installment").closest('.form-group').show();
$("#payment_date").closest('.form-group').hide();
$("#utr_no").closest('.form-group').hide();
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
if (row_count == 0 ) { addInstallmentHTML()}
// addInstallmentHTML()
}else{
console.log("inside else")
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
let remove_count = $("#no_of_installment").val();
console.log("row count",row_count);
if (row_count > 0 ) {
let ids = $installmentContainer.find('.form-row').slice(-remove_count).find('input[name="installment_primary_key[]"]').map(function() {
return $(this).val();
}).get();
Swal.fire({
title: "Do you want to remove all the entries?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, Proceed!"
}).then((result) => {
if (result.isConfirmed) {
let url = '<?= base_url('util/removeInstallments') ?>';
let requestData = { id: ids };
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
$("#no_of_installment").hide();
$("#payment_date").show();
$("#utr_no").show();
$("#no_of_installment").closest('.form-group').hide();
$("#payment_date").closest('.form-group').show();
$("#utr_no").closest('.form-group').show();
$('#installment_form_row').empty();
$('#no_of_installment').val("");
} else {
toastr.error(response.message, 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while removing the installment.', 'ERROR');
});
}else{
// alert("Inside else");
$('#no_of_installment').val(row_count);
// $("#is_installment_switch").bootstrapToggle('on');
// $('#is_installment_switch').val('1').change();
// $('#is_installment_switch').bootstrapToggle('on');
// $('#is_installment_switch').prop('checked', true).trigger('change');
$('#is_installment_switch').trigger('click'); // in some cases, this forces the CSS to update
}
});
}
}
})
$('#no_of_installment').on('change', function () {
let no_of_installments = parseInt($(this).val());
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
console.log("Form row count:", row_count);
if (row_count === 1) {
// $installmentContainer.empty();
for (let index = 0; index < no_of_installments - 1; index++) {
addInstallmentHTML();
}
} else if (no_of_installments === row_count) {
console.log('Same row count, no change needed.');
} else if (no_of_installments < row_count) {
// Remove extra rows from the end
let remove_count = row_count - no_of_installments;
let ids = $installmentContainer.find('.form-row')
.slice(-remove_count)
.find('input[name="installment_primary_key[]"]')
.map(function() {
return $(this).val();
}).get();
console.log('ids', ids);
if (Object.keys(ids).length > 0) {
Swal.fire({
title: "Do you want to remove the last " + (remove_count ?? "") + " entries?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, Proceed!"
}).then((result) => {
if (result.isConfirmed) {
let url = '<?= base_url('util/removeInstallments') ?>';
let requestData = { id: ids };
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
$installmentContainer.find('.form-row').slice(-remove_count).remove();
} else {
toastr.error(response.message, 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while removing the installment.', 'ERROR');
});
}else{
$('#no_of_installment').val(row_count);
}
});
} else {
$installmentContainer.find('.form-row').slice(-remove_count).remove();
}
} else if (no_of_installments > row_count) {
// Add extra rows from the end
let add_count = no_of_installments - row_count;
for (let index = 0; index < add_count; index++) {
addInstallmentHTML();
}
} else {
// Add missing rows
let add_count = no_of_installments - row_count;
for (let index = 0; index < add_count; index++) {
addInstallmentHTML();
}
}
});
function addInstallmentHTML() {
let html = `
<div class="form-row align-items-end">
<div class="form-group col-md-3">
<label for="installment_amount">Installment Amount</label>
<input type="text" class="form-control" name="installment_amount[]" placeholder="Enter Amount">
</div>
<div class="form-group col-md-3">
<label for="payment_date">Payment Date</label>
<input type="text" class="form-control payment_date" name="payment_date[]" placeholder="DD/MM/YYYY">
</div>
<div class="form-group col-md-3">
<label for="utr_no">UTR No.</label>
<input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No.">
</div>
<div class="form-group col-md-2">
<button type="button" class="btn btn-danger remove-installment">X</button>
</div>
</div>
`;
$('#installment_form_row').append(html);
$('.payment_date').flatpickr({
dateFormat: 'd/m/Y',
});
}
$(document).ready(function(){
setTimeout(function(){
$('.payment_date').flatpickr({
dateFormat: 'd/m/Y',
});
}, 2000)
// $('#is_installment_switch').bootstrapToggle();
})
$(document).on('click', '.remove-installment', function () {
let $this = $(this); // Store reference to the clicked element
let row_count = $('#installment_form_row .form-row').length;
console.log("row_count", row_count);
let id = $this.closest('.form-row').find('input[name="installment_primary_key[]"]').val() ?? null;
console.log("id", id);
let ids = id ? [id] : [];
console.log("ids", ids);
if (id != null && row_count > 1) {
Swal.fire({
title: "Do you want to remove this?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, Proceed!"
}).then((result) => {
if (result.isConfirmed) {
let url = '<?= base_url('util/removeInstallments') ?>';
let requestData = { id: ids };
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
$this.closest('.form-row').remove();
let updated_row_count = $('#installment_form_row .form-row').length;
$('#no_of_installment').val(updated_row_count);
console.log("after remove row_count", updated_row_count);
} else {
toastr.error(response.message, 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while removing the installment.', 'ERROR');
});
}
});
} else {
if (row_count > 1) {
$this.closest('.form-row').remove();
let updated_row_count = $('#installment_form_row .form-row').length;
$('#no_of_installment').val(updated_row_count);
console.log("after remove row_count", updated_row_count);
} else {
console.log("Only one row left. Not removing.");
}
}
});
</script>
<script>
class ExcessHandler {
change() {
throw new Error("Method 'change()' must be implemented.");
}
}
class DefaultExcessHandler extends ExcessHandler {
constructor(typeKey) {
super();
this.typeKey = typeKey;
}
change() {
getExcessData(this.typeKey);
}
}
const handlerMap = {
blu: new DefaultExcessHandler("blu"),
bsu: new DefaultExcessHandler("bsu"),
sfsp: new DefaultExcessHandler("sfsp"),
};
function modifyExcessTable(policyType) {
console.log("Policy Type from register: ", policyType);
const handler = handlerMap[policyType];
if (handler instanceof ExcessHandler) {
handler.change();
} else {
console.error(`No handler found for policyType: ${policyType}`);
}
}
function getExcessData(typeKey) {
const fire = dynamicExcessJson["excess_fire"][0][typeKey];
const burglary = dynamicExcessJson["excess_burglary"]?.[0]?.[typeKey] ?? null;
changeExcessTableDynamic(fire, burglary);
}
function changeExcessTableDynamic(fire, burglary = null) {
console.log("fire to be changed to: ", fire);
setExcessRowValues("fire", fire);
if (burglary != null) {
console.log("Burglary to be changed: ", burglary);
setExcessRowValues("burglary", burglary);
}
}
function setExcessRowValues(rowId, value) {
const table = document.getElementById("excess");
if (!table) return;
const rows = table.querySelectorAll(`tr[data-excess-row-parent="${rowId}"]`);
if (!rows.length) return;
const headerCells = table.querySelectorAll("thead tr:first-child th");
const subHeaderCells = table.querySelectorAll("thead tr:nth-child(2) th");
rows.forEach(row => {
const cells = row.querySelectorAll("td");
cells.forEach((cell, index) => {
const headerText = headerCells[index]?.textContent?.trim() || "";
const subHeaderText = subHeaderCells[index]?.textContent?.trim() || "";
if (
(headerText.startsWith("Proposal") || headerText.startsWith("Exi")) &&
subHeaderText.toLowerCase() === "sum insured"
) {
cell.textContent = value;
}
});
});
}
</script>
</script>