FIX_DEPENDENT_ADD_ERROR

This commit is contained in:
Srinivas-Saravanan 2025-05-03 17:35:15 +05:30
parent 4a0d9657d9
commit d76e999c93
8 changed files with 161 additions and 73 deletions

View File

@ -1035,6 +1035,14 @@ class EmployeeServiceController extends AdminController
// kint::dump($family);
$family = data_group_by_family($family)[ $emp_id ];// reason to call this again bring self to first index of the array
}
$firstNonTemp = null;
foreach ($family as $fam) {
if (!isset($fam['temp'])) {
$firstNonTemp = $fam;
break;
}
}
// kint::dump($family);//die();
//check name dup within a family
@ -1070,7 +1078,7 @@ class EmployeeServiceController extends AdminController
if(!count($self_details))
{
array_push($result['error_summary'],14); // Self not found
$result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in Database";
$result['error_data'][ $firstNonTemp[0] ]['sno']['error'][] = "Self not found in Database";
}
}
@ -1078,7 +1086,7 @@ class EmployeeServiceController extends AdminController
if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception'|| $file['action'] == 'missed_inception' || $file['action'] == 'enrollment')
{
$res = check_dependent_conflict($family,$policy_terms,$file['action'],$is_lgbtq);
// dd($res);
// Kint::dump($res);
if(!$res['status'])
{
foreach($res['error_data'] as $key => $value)
@ -1091,7 +1099,7 @@ class EmployeeServiceController extends AdminController
//check dup with empid and name with db
$res = name_and_empid_check_in_db($family,$file);
// dd($res);
// Kint::dump($res['del']);
// echo '<br/>';
// print_r($res);
if(count($res['del']))
@ -1113,7 +1121,7 @@ class EmployeeServiceController extends AdminController
}// end of foreach
}// end of if current action I,DA,A
// return $result;
// return $result;
// die();
if(isset($result['error_summary']) && count($result['error_summary']))
{

View File

@ -3077,6 +3077,7 @@ class LeadsController extends BaseController
3 => 'rfq/gmc',
4 => 'rfq/gmc',
5 => 'rfq/gmc',
17=> 'rfq/burglary',
22 => 'rfq/car',
23 => 'rfq/cpm',
24 => 'rfq/cyber_crime',

View File

@ -440,8 +440,20 @@ if (!function_exists('name_dup_check_within_family'))
foreach ($family_data as $rkey => $row)
{
if(in_array($row[2],$temp))
{
array_push($result,$row[0]);
{
// Kint::dump($row);
$emp_code = $row[1];
$tempFam = null;
foreach ($family_data as $family) {
if ($family[1] == $emp_code &&!isset($family['temp'])) {
$tempFam = $family;
break; // Stop at the first match
}
}
// Kint::dump($tempFam);
// die();
array_push($result,$tempFam[0]);
}
else
{
@ -449,7 +461,7 @@ if (!function_exists('name_dup_check_within_family'))
}
}
// dd($result);
return $result;
}
}
@ -519,7 +531,15 @@ if (!function_exists('name_and_empid_check_in_db'))
}
if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition' || $current_action == 'enrollment') && count($res))
{
array_push($result['i'],$row[0]);
$emp_code = $row[1];
$tempFam = null;
foreach ($family_data as $family) {
if ($family[1] == $emp_code &&!isset($family['temp'])) {
$tempFam = $family;
break; // Stop at the first match
}
}
array_push($result['i'],$tempFam[0]);
}
}

View File

@ -242,33 +242,33 @@ hr.solid {
</select>
</div>
<div class="form-group col-md-3">
<!-- <div class="form-group col-md-3">
<label for="insurer">Insurer <span class="text-danger"></span></label>
<select class="form-control" id="insurer" name="insurer">
<option value="">Select Insurer</option>
<?php if (isset($insurer)) { ?>
<?php foreach ($insurer as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>">
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
<?php //if (isset($insurer)) { ?>
<?php //foreach ($insurer as $value) { ?>
<option value="<?php //echo $value['id'] . '-' . $value['insurer_id'] ?>">
<?php //echo $value['insurer_name'] . '-' . $value['branch_code'] ?>
</option>
<?php } ?>
<?php } ?>
</select>
</div>
<?php //} ?>
<?php //} ?>
</select> -->
<!-- </div> -->
<div class="form-group col-md-3">
<!-- <div class="form-group col-md-3">
<label for="tpa">TPA <span class="text-danger"></span></label>
<select class="form-control" id="tpa" name="tpa">
<option value="">Select TPA</option>
<?php if (isset($tpa)) { ?>
<?php foreach ($tpa as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
<?php //if (isset($tpa)) { ?>
<?php //foreach ($tpa as $value) { ?>
<option value="<?php // echo $value['id'] . '-' . $value['tpa_id'] ?>">
<?php // echo $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
</option>
<?php } ?>
<?php } ?>
<?php //} ?>
<?php //} ?>
</select>
</div>
</div> -->
<div class="form-group col-md-3">
<label for="">Date of Commencement <span class="text-danger">*</span></label>

View File

@ -166,7 +166,21 @@
<option value="4_month">4 Months</option>
<option value="5_month">5 Months</option>
<option value="6_month">6 Months</option>
<option value="7_month">7 Months</option>
<option value="8_month">8 Months</option>
<option value="9_month">9 Months</option>
<option value="10_month">10 Months</option>
<option value="11_month">11 Months</option>
<option value="12_month">12 Months</option>
<option value="2_year">2 Year</option>
<option value="3_year">3 Year</option>
<option value="4_year">4 Year</option>
<option value="5_year">5 Year</option>
<option value="6_year">6 Year</option>
<option value="7_year">7 Year</option>
<option value="8_year">8 Year</option>
<option value="9_year">9 Year</option>
<option value="10_year">10 Year</option>
</select>
</div>
<div id="locationNoDIV" class="form-group col-md-4">
@ -358,7 +372,7 @@
$("#policyRiskSplitUpForm").submit(function(event) {
event.preventDefault();
var isValid = $('#policyRiskSplitUpForm').parsley().validate();
// console.log('isValid', isValid);
@ -403,25 +417,25 @@
let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0);
let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0);
let allowedSI = Number($("#policySI").val()) || 0;
if (totalSI > allowedSI) {
if (totalSI != allowedSI) {
toastr.error("Sum Insured Exceeds Allowed Limit", "ERROR");
return false;
return false;
}
// console.log("Total SI: ", totalSI);
}else{
} else {
let InProcess = [...document.querySelectorAll('[id^="stockInProcess_"]')].map(el => Number(el.value) || 0);
let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0);
let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0);
}
}
@ -465,6 +479,7 @@
// console.log("Grouped Data as Objects: ", policyRiskSplitUpData);
savePolicyDataLocal();
});
@ -678,7 +693,7 @@
<input type="number" id="rawMaterial_${increment2}" name="raw_material[]" class="form-control multi_location_company" />
</div>
<div class="form-group col-md-4 multi_location_company">
<label for="finishedStock_${increment2}">Finished Stock</label>
<label for="finishedStock_${increment2}">Stock</label>
<input type="number" id="finishedStock_${increment2}" name="finished_stock[]" class="form-control multi_location_company"/>
</div>
</div>
@ -790,11 +805,11 @@
</select>
</div>
<div class="form-group col-md-4">
<label for="basementSI_${increment}">Basement Sum Insured</label>
<label for="basementSI_${increment}">Basement Utilisation</label>
<input type="text" id="basementSI_${increment}" name="basement_si[]" class="form-control"/>
</div>
<div class="form-group col-md-4">
<label for="occupancy_${increment}">Occupancy<span class="text-danger">*</span></label>
<label for="occupancy_${increment}">Occupancy Risk<span class="text-danger">*</span></label>
<select id="occupancy_${increment}" name="occupancy[]" class="form-control" onchange="showRequiredFieldsBasedOnLocation('occupancy_${increment}')" required>
<option value="">Select</option>
${occupancyMaster.map(occupancy =>
@ -1067,17 +1082,17 @@
var policyType;
if (totalSI<50000000){
if (totalSI < 50000000) {
policyType = "Bharat Sookshma Udyam Suraksha (BSUS)"
} else if (totalSI > 50000000 && totalSI < 500000000){
} else if (totalSI > 50000000 && totalSI < 500000000) {
policyType = "Bharat Laghu Udyam Suraksha (BLUS)"
}else if (totalSI >500000000 ){
} else if (totalSI > 500000000) {
policyType = "Standard Fire and Special Perils (SFSP)";
}
}
// Build the initial JSON object with productSelection and policyDetails
var outputData = {
policyType:policyType,
policyType: policyType,
productSelection: productSelectionData,
policyDetails: policyDetailsData,
locations: []
@ -1127,18 +1142,19 @@
// Save the updated data back to localStorage
localStorage.setItem('policyData', JSON.stringify(existingData));
if (!$.isEmptyObject(existingData)) {
// console.log("DATA FROM DB : ", (existingData));
let data = (existingData);
Object.keys(data).forEach(key => {
policySummary[key] = addPolicySummaryTable(data[key], key);
prependTable(policySummary[key],key);
prependTable(policySummary[key], key);
});
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
toastr.success("Policy Information Collected ","SUCCESS");
toastr.success("Policy Information Collected ", "SUCCESS");
closeModal();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
// console.log("Updated policy data in localStorage:", existingData);
@ -1220,7 +1236,7 @@
loadPolicyDataBack(data);
assignDataToFields(data);
// alert("inside else");
}else{
} else {
// alert("nothing");
}
// console.log("policy data : ", data);
@ -1332,10 +1348,10 @@
function assignLeadData() {
const lead_data = <?= json_encode(json_decode($lead_data['custom_fields'])) ?>;
var clientName = <?= isset($lead_data['client_name']) ? json_encode($lead_data['client_name']) : ""?>;
var clientName = <?= isset($lead_data['client_name']) ? json_encode($lead_data['client_name']) : "" ?>;
var client_type = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
var mobile = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
var email = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
var mobile = <?= isset($lead_data['contact_person_mobile']) ? $lead_data['contact_person_mobile'] : "" ?>;
var contact_email = "<?= isset($lead_data['contact_person_email']) ? $lead_data['contact_person_email'] : "" ?>";
var panNo = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
// console.log("client_type : ".client_type);
if (lead_data) {
@ -1361,6 +1377,8 @@
$("#client_type").val(client_type).trigger("change");
$("#insured_name").val(clientName);
$("#address1").val(lead_data.address);
$("#mobile").val(mobile);
$("#email").val(contact_email);
}
}
@ -1429,4 +1447,17 @@
hideAndShowBurglary();
}
$(document).on('input', 'input[id^="pin_code"]', function() {
// alert("inside");
let value = $(this).val().replace(/\D/g, '').slice(0, 6);
$(this).val(value);
});
function closeModal() {
document.querySelector('#policyRegisterModel [data-dismiss="modal"]').click();
}
</script>

View File

@ -0,0 +1,28 @@
<hr>
<div class="form-row custom_fields">
<!-- Risk Location -->
<div class="form-group col-md-6">
<label>Risk Location</label><br>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="risk_location" value="single" <?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'single' ? 'checked' : ''; ?>>
<label class="form-check-label">Single</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="risk_location" value="multi_with_floter" <?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'multi_with_floter' ? 'checked' : ''; ?>>
<label class="form-check-label">Multi with Floter</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="risk_location" value="multi_without_floter" <?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'multi_without_floter' ? 'checked' : ''; ?>>
<label class="form-check-label">Multi without Floter</label>
</div>
</div>
<!-- Address -->
<div class="form-group col-md-6">
<label for="address">Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>
</div>

View File

@ -2,7 +2,7 @@
<div class="form-row custom_fields">
<!-- Risk Location -->
<div class="form-group col-md-6">
<!-- <div class="form-group col-md-6">
<label>Risk Location</label>
<div>
<?php
@ -21,7 +21,7 @@
<label class="form-check-label" for="multi_no_floater">Multi without Floater</label>
</div>
</div>
</div>
</div> -->
<!-- Policy Period -->
<div class="form-group col-md-3">

View File

@ -536,7 +536,7 @@
// alert(rollover_or_renewal);
var policyConfig = {
1: ['Quote asked']
1: ['Sum Insured']
};
let myModal;
@ -634,7 +634,7 @@
let proposalCount = 1;
// // console.log("Proposal count changed", proposalCount);
let quotesConfig = {
1: ['Quote asked']
1: ['Sum Insured']
}; // Stores quote columns for each proposal
@ -1002,8 +1002,8 @@
proposalCount++;
// // console.log("proposal count after ", proposalCount);
quotesConfig[proposalCount] = ['Quote asked'];
policyConfig[proposalCount] = ['Quote asked'];
quotesConfig[proposalCount] = ['Sum Insured'];
policyConfig[proposalCount] = ['Sum Insured'];
const tables = document.querySelectorAll('table');
let increaseBy = 150;
increaseTableWidth(increaseBy);
@ -1037,7 +1037,7 @@
// Add new quote sub-header
const newQuoteHeader = document.createElement('th');
newQuoteHeader.textContent = 'Quote asked';
newQuoteHeader.textContent = 'Sum Insured';
newQuoteHeader.style.backgroundColor = randomColor;
headerRow2.insertBefore(newQuoteHeader, headerRow2.querySelector('th:last-child'));
@ -1593,7 +1593,7 @@
<th>-</th>
${Object.entries(quotesConfig).flatMap(([proposal, codes]) =>
codes.map(code => `
<th data-proposal="${proposal}" data-quote="${code}" class="${code !== 'Quote asked' ? 'insurer_proposal' : ''}">
<th data-proposal="${proposal}" data-quote="${code}" class="${code !== 'Sum Insured' ? 'insurer_proposal' : ''}">
${code}
<span class="three-dot-menu" onclick="showDropdown(event)">&#8942;</span>
<div class="dropdown-content">
@ -1723,8 +1723,8 @@
// }
let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : '';
// // console.log("Subheader th: below code",subHeaderText);
// Check if subheader is NOT "Quote asked"
let className = !subHeaderText.startsWith("Quote asked") && subHeaderText != "-" ?
// Check if subheader is NOT "Sum Insured"
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" ?
"insurer_proposal" : "";
// console.log("className", className);
// alert(subHeaderText);
@ -1826,8 +1826,8 @@
let subHeaderTh = validSubHeaders.find(th => th.textContent.trim());
let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : '';
// Check if subheader is NOT "Quote asked"
let className = !subHeaderText.startsWith("Quote asked") && subHeaderText != "-" ?
// Check if subheader is NOT "Sum Insured"
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" ?
"insurer_proposal" : ""; // alert(subHeaderText);
let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
@ -2820,8 +2820,8 @@
// if (!proposalNumber) return; // Skip if extraction fails
// Initialize with "Quote asked"
result[proposalNumber] = ["Quote asked"];
// Initialize with "Sum Insured"
result[proposalNumber] = ["Sum Insured"];
// Check if insurers exist and filter those with qcr = 1
if (Array.isArray(proposalData.insurers)) {
@ -2862,8 +2862,8 @@
let proposal = overallColumnData[proposalKey];
let insurersList = proposal.insurers.map(ins => ins.ins_name); // Extract insurer names
// Create output format: index { "Quote asked", ...insurers }
quotesConfiguration[index] = ["Quote asked", ...insurersList];
// Create output format: index { "Sum Insured", ...insurers }
quotesConfiguration[index] = ["Sum Insured", ...insurersList];
});
@ -3032,13 +3032,13 @@
if (lead_type == 1){
td.onclick = () => getAnswer(table.id, tr.id);
if (cellData.subth != "Quote asked") {
if (cellData.subth != "Sum Insured") {
td.onclick = () => getAnswer(table.id, tr.id);
td.classList.add("insurer_proposal");
}
}else{
td.onclick = () => getAnswer(table.id, tr.id);
if (cellData.subth != "Quote asked") {
if (cellData.subth != "Sum Insured") {
td.onclick = () => getAnswer(table.id, tr.id);
td.classList.add("insurer_proposal");
}
@ -3246,7 +3246,7 @@
const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader);
if (subHeader != "Quote asked") {
if (subHeader != "Sum Insured") {
// // console.log("trying to find something : matchedInsurer", matchedInsurer);
// // console.log("trying to find something :matchedInsurer stc ", matchedInsurer.stc);
// // console.log("trying to find something : ", matchedInsurer.stc);
@ -3642,7 +3642,7 @@
}
function makeQuoteAskedColumnNonEditableorEditable() {
// alert("Quote asked");
// alert("Sum Insured");
$("table").each(function() {
var table = $(this);
var subHeaderRow = table.find("tr:nth-child(2)"); // Assuming second row is the sub-header
@ -3652,18 +3652,18 @@
var colIndexTracker = []; // Maps visual column index to actual index
var visualIndex = 0; // Tracks the visual column position considering rowspan/colspan
// Step 1: Find the "Quote asked" column index
// Step 1: Find the "Sum Insured" column index
subHeaderRow.children("th, td").each(function(actualIndex) {
colIndexTracker[visualIndex] = actualIndex;
if ($(this).text().trim() === "Quote asked") {
if ($(this).text().trim() === "Sum Insured") {
targetColumnIndexes.push(visualIndex);
}
visualIndex += parseInt($(this).attr("colspan") || 1, 10);
});
if (targetColumnIndexes === 0) return; // If "Quote asked" column is not found, exit
if (targetColumnIndexes === 0) return; // If "Sum Insured" column is not found, exit
// Step 2: Make all cells in the found column non-editable, considering rowspan
var rowSpans = {}; // Keeps track of rowspans per column