FIX_LEAD_PAGE_ISSUE : RV
This commit is contained in:
parent
ac98ef4c97
commit
d86c0941a6
@ -362,13 +362,13 @@ class LeadsController extends BaseController
|
||||
// $premium_date = null;
|
||||
// }
|
||||
|
||||
if (!empty($data['source_policy_start_date'])) {
|
||||
if (!empty($data['source_policy_start_date']) && $data['lead_type'] == 2) {
|
||||
$data['source_policy_start_date'] = change_date_format($data['source_policy_start_date'], 'd/m/Y', 'Y-m-d');
|
||||
} else {
|
||||
$data['source_policy_start_date'] = null;
|
||||
}
|
||||
|
||||
if (!empty($data['source_policy_end_date'])) {
|
||||
if (!empty($data['source_policy_end_date']) && $data['lead_type'] == 2) {
|
||||
$data['source_policy_end_date'] = change_date_format($data['source_policy_end_date'], 'd/m/Y', 'Y-m-d');
|
||||
} else {
|
||||
$data['source_policy_end_date'] = null;
|
||||
|
||||
@ -552,7 +552,7 @@
|
||||
})
|
||||
//------------------------------ GET DATA ( EDIT, BRANCH, POLICY ) ---------------------------------------------------------------------------
|
||||
|
||||
//view and edit Lead data function
|
||||
//view and edit Lead data function ( NOT IN USE DON'T DELETE )
|
||||
function getLeadsDataForEdit(input) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
@ -608,9 +608,9 @@
|
||||
$('.lifeClaimFields').show();
|
||||
} else {
|
||||
|
||||
updateRenewalFields(dataIncrement);
|
||||
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
// let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
// updateRenewalFields(dataIncrement);
|
||||
// let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
let incurred_claim_date_id = 'incurred_claim_date';
|
||||
|
||||
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
@ -976,10 +976,12 @@
|
||||
$('.lifeClaimFields').show();
|
||||
} else {
|
||||
|
||||
updateRenewalFields(dataIncrement);
|
||||
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
// let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
|
||||
if(lead_type == 1){
|
||||
updateRenewalFields(dataIncrement);
|
||||
}
|
||||
|
||||
// let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
let incurred_claim_date_id = 'incurred_claim_date';
|
||||
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
@ -1007,11 +1009,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
// var premium_date_datepicker = flatpickr("#" + premium_date_id, {
|
||||
// dateFormat: "d/m/Y",
|
||||
// allowInput: false
|
||||
// });
|
||||
|
||||
$('#proposed_insurer_' + dataIncrement).select2();
|
||||
$('#proposed_tpa_' + dataIncrement).select2();
|
||||
|
||||
@ -1181,14 +1178,14 @@
|
||||
|
||||
$('#source_policy_id').on('change', function() {
|
||||
let client_policy_id = $(this).val();
|
||||
console.log('increment given', increment)
|
||||
console.log('increment given', increment);
|
||||
getPolicyData(client_policy_id, increment);
|
||||
})
|
||||
|
||||
if (check == 1) {
|
||||
let client_policy_id = $('#source_policy_id').val();
|
||||
if (client_policy_id) {
|
||||
getPolicyData(client_policy_id, increment)
|
||||
getPolicyData(client_policy_id, increment);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1354,23 +1351,29 @@
|
||||
console.log('Lead Type:', lead_type);
|
||||
|
||||
let increment = input.id.split('_').pop(); // Extract increment
|
||||
if(lead_type != 1){
|
||||
increment = "1";
|
||||
if(lead_type == 1){
|
||||
return;
|
||||
}
|
||||
|
||||
let input_id = input.id;
|
||||
console.log('--- calculatePolicyMetrics called ---');
|
||||
console.log('Input ID:', input.id);
|
||||
console.log('Input ID:', input_id);
|
||||
console.log('Increment:', increment);
|
||||
|
||||
let sourcePolicyDateVal = $('#source_policy_start_date').val()?.trim();
|
||||
let policyStartDateVal = $('#policy_start_date').val()?.trim();
|
||||
let policyStartDateVal = $('#policy_start_date').val()?.trim() || $('#policy_start_date_1').val()?.trim();
|
||||
|
||||
let policyStartDateInput = null;
|
||||
|
||||
if (sourcePolicyDateVal) {
|
||||
if (sourcePolicyDateVal && lead_type == 2) {
|
||||
policyStartDateInput = $('#source_policy_start_date');
|
||||
console.log('Using Source Policy Start Date:', sourcePolicyDateVal);
|
||||
} else if (policyStartDateVal) {
|
||||
policyStartDateInput = $('#policy_start_date');
|
||||
if(input_id == "policy_start_date_1"){
|
||||
policyStartDateInput = $('#policy_start_date_1');
|
||||
}else{
|
||||
policyStartDateInput = $('#policy_start_date');
|
||||
}
|
||||
console.log('Using Policy Start Date:', policyStartDateVal);
|
||||
} else {
|
||||
toastr.warning('Policy start date or Date of Commencement is empty. Please fill in the date field.', "WARNING.. !");
|
||||
@ -1383,7 +1386,7 @@
|
||||
console.log('Policy Start Date Input:', policyStartDateInput.val());
|
||||
|
||||
let policyStartDate = flatpickr.parseDate(policyStartDateInput.val(), "d/m/Y");
|
||||
let incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
|
||||
let incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date").val(), "d/m/Y");
|
||||
|
||||
console.log('Parsed Policy Start Date:', policyStartDate);
|
||||
console.log('Parsed Incurred Claim Date:', incurredClaimDate);
|
||||
@ -1395,28 +1398,28 @@
|
||||
let daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24) + 1);
|
||||
console.log('Policy Run Days:', daysDiff);
|
||||
|
||||
$('#policy_run_days_' + increment).val(daysDiff);
|
||||
$('#policy_run_days').val(daysDiff);
|
||||
}
|
||||
|
||||
let paid_claims = Number($('#paid_claims_' + increment).val()) || 0;
|
||||
let outstanding_claims = Number($('#outstanding_claims_' + increment).val()) || 0;
|
||||
let paid_claims = Number($('#paid_claims').val()) || 0;
|
||||
let outstanding_claims = Number($('#outstanding_claims').val()) || 0;
|
||||
console.log('Paid Claims:', paid_claims);
|
||||
console.log('Outstanding Claims:', outstanding_claims);
|
||||
|
||||
let incurred_claims = paid_claims + outstanding_claims;
|
||||
console.log('Incurred Claims:', incurred_claims);
|
||||
$('#incurred_claims_' + increment).val(incurred_claims);
|
||||
$('#incurred_claims').val(incurred_claims);
|
||||
|
||||
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
let policy_run_days = Number($('#policy_run_days').val()) || 0;
|
||||
console.log('Policy Run Days (Final):', policy_run_days);
|
||||
|
||||
let annualised_claims = policy_run_days > 0 ? (incurred_claims / policy_run_days) * 365 : 0;
|
||||
let annualised_claims_roundoff = Math.round(annualised_claims);
|
||||
console.log('Annualised Claims:', annualised_claims);
|
||||
console.log('Annualised Claims (Rounded):', annualised_claims_roundoff);
|
||||
$('#annualised_claims_' + increment).val(annualised_claims_roundoff);
|
||||
$('#annualised_claims').val(annualised_claims_roundoff);
|
||||
|
||||
let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
let premium_as_on_date = Number($('#premium_date').val()) || 0;
|
||||
console.log('Premium as on Date:', premium_as_on_date);
|
||||
|
||||
let incurred_claim_ratio = (annualised_claims > 0 && premium_as_on_date > 0)
|
||||
@ -1425,19 +1428,19 @@
|
||||
let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio) ? Math.round(incurred_claim_ratio) : 0;
|
||||
console.log('Incurred Claim Ratio:', incurred_claim_ratio);
|
||||
console.log('Incurred Claim Ratio (Rounded):', incurred_claim_ratio_roundoff);
|
||||
$('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio_roundoff);
|
||||
$('#incurred_claims_ratio').val(incurred_claim_ratio_roundoff);
|
||||
|
||||
let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0;
|
||||
let earned_premium_roundoff = Math.round(earned_premium);
|
||||
console.log('Earned Premium:', earned_premium);
|
||||
console.log('Earned Premium (Rounded):', earned_premium_roundoff);
|
||||
$('#earned_premium_' + increment).val(earned_premium_roundoff);
|
||||
$('#earned_premium').val(earned_premium_roundoff);
|
||||
|
||||
let earnedClaimsRatio = earned_premium > 0 ? annualised_claims / earned_premium : 0;
|
||||
let earnedClaimsRatioRounded = Math.round(earnedClaimsRatio);
|
||||
console.log('Earned Claims Ratio:', earnedClaimsRatio);
|
||||
console.log('Earned Claims Ratio (Rounded):', earnedClaimsRatioRounded);
|
||||
$('#earned_claims_ratio_' + increment).val(earnedClaimsRatioRounded);
|
||||
$('#earned_claims_ratio').val(earnedClaimsRatioRounded);
|
||||
|
||||
console.log('--- End of calculatePolicyMetrics ---\n');
|
||||
}
|
||||
@ -1593,6 +1596,78 @@
|
||||
removeExtraForms();
|
||||
}
|
||||
|
||||
$('#contact_person_summary').empty();
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select a Contact"
|
||||
}));
|
||||
|
||||
$("#gst").val("");
|
||||
$("#branch_name").val("");
|
||||
$("#branch_code").val("");
|
||||
$("#contact_person_name").val("");
|
||||
$("#contact_person_mobile").val("");
|
||||
$("#contact_person_email").val("");
|
||||
|
||||
|
||||
// Fresh fields
|
||||
$("#client_type").prop("selectedIndex", 0);
|
||||
$("#entity_type_id").prop("selectedIndex", 0);
|
||||
$("#client_name").val("");
|
||||
$("#client_short_name").val("");
|
||||
|
||||
// Renewal fields
|
||||
$("#client_id").prop("selectedIndex", 0);
|
||||
$("#client_branch_id").prop("selectedIndex", 0);
|
||||
$("#source_policy_id").empty();
|
||||
$('#source_policy_id').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select a Policy"
|
||||
}));
|
||||
$("#pan").val("");
|
||||
|
||||
$('#policy_type_id_1').prop("selectedIndex", 0)
|
||||
$('#insurer_1').prop("selectedIndex", 0)
|
||||
$('#tpa_1').prop("selectedIndex", 0);
|
||||
$('#policy_start_date').val("");
|
||||
$('#policy_end_date').val("");
|
||||
$("#appendArea_1").empty();
|
||||
|
||||
// $('#source_policy_start_date').val("");
|
||||
// $('#source_policy_end_date').val("");
|
||||
// $('#incurred_claims_date').val("");
|
||||
// $('#paid_claims').val("");
|
||||
// $('#outstanding_claims').val("");
|
||||
// $('#incurred_claims').val("");
|
||||
// $('#policy_run_days').val("");
|
||||
// $('#premium_at_inception').val("");
|
||||
// $('#premium_date').val("");
|
||||
// $('#earned_premium').val("");
|
||||
// $('#annualised_claims').val("");
|
||||
// $('#incurred_claims_ratio').val("");
|
||||
// $('#earned_claims_ratio').val("");
|
||||
|
||||
let incurred_claim_date_id = 'incurred_claim_date';
|
||||
if ($('#' + incurred_claim_date_id).length) {
|
||||
flatpickr("#" + incurred_claim_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
onChange: function (selectedDates) {
|
||||
try {
|
||||
let increment = this.input.id.split('_').pop();
|
||||
let policyStartDate = $("#source_policy_start_date");
|
||||
if (policyStartDate.val()) {
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in incurred_claim_datepicker:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn(`Incurred claim date field #${incurred_claim_date_id} not found.`);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
function insurerChange(input, unique_id) {
|
||||
|
||||
@ -593,9 +593,8 @@ if (isset($selected_lead_type)) {
|
||||
$('.lifeClaimFields').show();
|
||||
} else {
|
||||
// updateRenewalFields(dataIncrement);
|
||||
|
||||
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
// let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
// let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
let incurred_claim_date_id = 'incurred_claim_date';
|
||||
|
||||
if ($('#' + incurred_claim_date_id).length) {
|
||||
flatpickr("#" + incurred_claim_date_id, {
|
||||
@ -617,15 +616,6 @@ if (isset($selected_lead_type)) {
|
||||
console.warn(`Incurred claim date field #${incurred_claim_date_id} not found.`);
|
||||
}
|
||||
|
||||
// if ($('#' + premium_date_id).length) {
|
||||
// flatpickr("#" + premium_date_id, {
|
||||
// dateFormat: "d/m/Y",
|
||||
// allowInput: false
|
||||
// });
|
||||
// } else {
|
||||
// console.warn(`Premium date field #${premium_date_id} not found.`);
|
||||
// }
|
||||
|
||||
// console.log($('#proposed_insurer_' + dataIncrement).length);
|
||||
$('#proposed_insurer_' + dataIncrement).select2();
|
||||
$('#proposed_tpa_' + dataIncrement).select2();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
<?php $increment = isset($lead_edit_data) ? "_1" : ''; ?>
|
||||
<?php $increment = isset($lead_edit_data) ? "" : ''; ?>
|
||||
<hr>
|
||||
|
||||
<div class="form-row renewalCalculation">
|
||||
@ -132,21 +132,21 @@
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="incept_emp_count" class="emp_title"> No of Employees at Inception <span
|
||||
class="text-danger">*</span></label>
|
||||
class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['incept_emp_count']) ? $lead_edit_data['incept_emp_count'] : '' ?>" type="text" class="form-control" id="incept_emp_count" name="incept_emp_count[]"
|
||||
placeholder="Enter Lives" required oninput="calculateTotalLives(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="incept_dept_count" class="depnd_title"> No of Dependents at Inception <span
|
||||
class="text-danger">*</span></label>
|
||||
class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['incept_dept_count']) ? $lead_edit_data['incept_dept_count'] : '' ?>" type="text" class="form-control" id="incept_dept_count" name="incept_dept_count[]"
|
||||
placeholder="Enter Lives" required oninput="calculateTotalLives(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="incept_no_of_lives" class="total_title"> Total Lives at Inception <span
|
||||
class="text-danger">*</span></label>
|
||||
class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['incept_no_of_lives']) ? $lead_edit_data['incept_no_of_lives'] : '' ?>" type="text" class="form-control" id="incept_no_of_lives" name="incept_no_of_lives[]"
|
||||
placeholder="Enter Lives" required>
|
||||
</div>
|
||||
@ -156,20 +156,20 @@
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="exp_emp_count"> No of Employees at Expiry <span class="text-danger">*</span></label>
|
||||
<label for="exp_emp_count"> No of Employees at Expiry <span class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['exp_emp_count']) ? $lead_edit_data['exp_emp_count'] : '' ?>" type="text" class="form-control" id="exp_emp_count" name="exp_emp_count[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="exp_dept_count"> No of Dependents at Expiry <span
|
||||
class="text-danger">*</span></label>
|
||||
class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['exp_dept_count']) ? $lead_edit_data['exp_dept_count'] : '' ?>" type="text" class="form-control" id="exp_dept_count" name="exp_dept_count[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="exp_no_of_lives"> Total Lives at Expiry <span class="text-danger">*</span></label>
|
||||
<label for="exp_no_of_lives"> Total Lives at Expiry <span class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['exp_no_of_lives']) ? $lead_edit_data['exp_no_of_lives'] : '' ?>" type="text" class="form-control" id="exp_no_of_lives" name="exp_no_of_lives[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
@ -180,21 +180,21 @@
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="renewal_emp_count"> No of Employees at Renewal <span
|
||||
class="text-danger">*</span></label>
|
||||
class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['renewal_emp_count']) ? $lead_edit_data['renewal_emp_count'] : '' ?>" type="text" class="form-control" id="renewal_emp_count" name="renewal_emp_count[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="renewal_dept_count"> No of Dependents at Renewal <span
|
||||
class="text-danger">*</span></label>
|
||||
class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['renewal_dept_count']) ? $lead_edit_data['renewal_dept_count'] : '' ?>" type="text" class="form-control" id="renewal_dept_count" name="renewal_dept_count[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="renewal_no_of_lives"> Total Lives at Renewal <span
|
||||
class="text-danger">*</span></label>
|
||||
class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['renewal_no_of_lives']) ? $lead_edit_data['renewal_no_of_lives'] : '' ?>" type="text" class="form-control" id="renewal_no_of_lives" name="renewal_no_of_lives[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user