FIX_RFQ_SRI
This commit is contained in:
parent
d576de46f9
commit
7d1c149a59
@ -1982,6 +1982,13 @@ class ClientController extends AdminController
|
||||
->findAll();
|
||||
$client_policy_list = $this->clientPolicyModel->getPolicyTypeForPolicyBinding($client_id);
|
||||
$cd_data = $this->CDMasterModel->where('client_id', $client_id)->where('insurer_id', $insurer_id)->findAll();
|
||||
$client_policy_data['policy_end_date'] = date('d/m/Y', strtotime($client_policy_data['policy_end_date']));
|
||||
$fromDate = $client_policy_data['policy_end_date'];
|
||||
$date = \DateTime::createFromFormat('d/m/Y', $fromDate);
|
||||
$date->modify('+1 year');
|
||||
$newDate = $date->format('d/m/Y');
|
||||
|
||||
// print_rr($client_policy_data['policy_end_date']);die();
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
@ -1990,7 +1997,8 @@ class ClientController extends AdminController
|
||||
'cd_data' => $cd_data,
|
||||
"insurer_id" => $client_policy_data['insurer_id'],
|
||||
'policy' => $polices,
|
||||
'client_policy_list' => $client_policy_list
|
||||
'client_policy_list' => $client_policy_list,
|
||||
'end_date' => $newDate
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
|
||||
@ -279,13 +279,58 @@
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end form row -->
|
||||
<script>
|
||||
setTimeout(() => {
|
||||
var policyStart = $(".policy_start_date");
|
||||
var policyEnd = $(".policy_end_date");
|
||||
|
||||
if (policyStart.length === 0 || policyEnd.length === 0) {
|
||||
console.log("Elements still not found after delay.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Elements found, setting IDs...");
|
||||
|
||||
var lead_type = $('#lead_type').val();
|
||||
var increment = 1;
|
||||
var start_date_id = lead_type == "1" ? `policy_start_date_${increment}` : "policy_start_date";
|
||||
var end_date_id = lead_type == "1" ? `policy_end_date_${increment}` : "policy_end_date";
|
||||
|
||||
policyStart.attr("id", start_date_id);
|
||||
$("label[for='policy_start_date'], label[for^='policy_start_date_']").attr("for", start_date_id);
|
||||
|
||||
policyEnd.attr("id", end_date_id);
|
||||
$("label[for='policy_end_date'], label[for^='policy_end_date_']").attr("for", end_date_id);
|
||||
}, 3000);
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
//SELECT2 document ready function
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#lead_type").change(function () {
|
||||
$("input, select").removeClass("readonly-select");
|
||||
$("input, select").removeAttr("readonly");
|
||||
|
||||
var lead_type = $(this).val();
|
||||
var increment = 1; // Example increment value (modify as needed)
|
||||
var start_date_id = lead_type == "1" ? `policy_start_date_${increment}` : "policy_start_date";
|
||||
var end_date_id = lead_type == "1" ? `policy_end_date_${increment}`:"policy_end_date";
|
||||
|
||||
$(".policy_start_date").attr("id", start_date_id);
|
||||
$("label[for]").attr("for", start_date_id);
|
||||
|
||||
$(".policy_end_date").attr("id", end_date_id);
|
||||
$("label[for]").attr("for", end_date_id);
|
||||
|
||||
// $('#leads_form_id')[0].reset();
|
||||
|
||||
// console.log("Updated ID:", newId);
|
||||
});
|
||||
|
||||
|
||||
getURLParamsForReport()
|
||||
addHTMLInput()
|
||||
setTimeout(function() {
|
||||
@ -359,7 +404,8 @@ function getLeadsDataForEdit(input) {
|
||||
|
||||
$('#page_title').text(page_title);
|
||||
$('#leads_primarykey').val(res.data.id);
|
||||
|
||||
console.log('policy start date : '+ res.data.policy_end_date);
|
||||
$('#policy_start_date').val(res.data.policy_end_date);
|
||||
$('#lead_type').val(res.data.lead_type);
|
||||
$('#issuer').val(res.data.issuer);
|
||||
$('#client_type').val(res.data.client_type);
|
||||
@ -385,6 +431,7 @@ function getLeadsDataForEdit(input) {
|
||||
$('#contact_person_mobile').val(res.data.contact_person_mobile);
|
||||
$('#contact_person_email').val(res.data.contact_person_email);
|
||||
$('#policy_type_id_1').val(res.data.policy_type_id).change();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000)
|
||||
@ -480,7 +527,7 @@ function getLeadsDataForEdit(input) {
|
||||
}
|
||||
|
||||
if(res.data.policy_type_id != 2){
|
||||
|
||||
|
||||
$('.gpa_hide_div_'+increment).hide();
|
||||
$('.gpa_show_div_'+increment).show();
|
||||
$('.gpa_div_elements_'+increment).show();
|
||||
@ -548,6 +595,16 @@ function getBranchData(input) {
|
||||
$('#contact_person_mobile').val(res.contact.mobile);
|
||||
$('#contact_person_email').val(res.contact.email);
|
||||
|
||||
|
||||
$('#pan').prop('readOnly',true);
|
||||
$('#gst').prop('readOnly',true);
|
||||
$('#branch_name').prop('readOnly',true);
|
||||
$('#branch_code').prop('readOnly',true);
|
||||
$('#contact_person_name').prop('readOnly',true);
|
||||
$('#contact_person_mobile').prop('readOnly',true);
|
||||
$('#contact_person_email').prop('readOnly',true);
|
||||
$('#policy_type_id_1').prop('readOnly',true);
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
@ -562,6 +619,7 @@ function getBranchData(input) {
|
||||
$('#contact_person_email').val('');
|
||||
|
||||
console.log(res.message, 'warning');
|
||||
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
@ -606,10 +664,20 @@ function getPolicyData(client_policy_id, increment_count) {
|
||||
$(`#tpa_${i}`).val(tpa).trigger('change');
|
||||
$(`#proposed_insurer_${i}`).val(insurer).trigger('change');
|
||||
$(`#proposed_tpa_${i}`).val(tpa).trigger('change');
|
||||
}
|
||||
$('#policy_start_date').val(res.data.policy_end_date);
|
||||
$('#policy_end_date').val(res.end_date);
|
||||
|
||||
$("#policy_end_date").prop('readOnly',true);
|
||||
$("#policy_start_date").prop("readOnly", true);
|
||||
$(`#policy_type_id_${i}`).addClass('readonly-select ').select2('destroy');
|
||||
$(`#insurer_${i}`).addClass('readonly-select ').select2('destroy');
|
||||
$(`#tpa_${i}`).addClass('readonly-select ').select2('destroy');
|
||||
// $(`#proposed_insurer_${i}`).addClass('readonly-select ').select2('destroy');
|
||||
// $(`#proposed_tpa_${i}`).addClass('readonly-select ').select2('destroy');
|
||||
|
||||
}
|
||||
} else {
|
||||
console.warn('Invalid response:', res.message || 'Unknown error');
|
||||
|
||||
// Reset fields if response is invalid
|
||||
for (let i = 1; i <= increment_count; i++) {
|
||||
$(`#policy_type_id_${i}`).val('').trigger('change');
|
||||
@ -765,15 +833,14 @@ function addHTMLInput(check) {
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_start_date_${increment}">Date of Commencement <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC">
|
||||
<label for="">Date of Commencement <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_start_date" id="" name="policy_start_date[]" placeholder="Enter DOC">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_end_date_${increment}">Date of Expiry <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE">
|
||||
<label for="">Date of Expiry <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_end_date" id="" name="policy_end_date[]" placeholder="Enter DOE">
|
||||
</div>
|
||||
`;
|
||||
|
||||
@ -802,7 +869,7 @@ function addHTMLInput(check) {
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="policy_run_days_${increment}">Policy Run Days<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="policy_run_days_${increment}" name="policy_run_days[]" placeholder="Enter Policy Run Days" oninput="earnedPremiumCalc(this)">
|
||||
<input type="text" class="form-control" id="policy_run_days_${increment}" name="policy_run_days[]" placeholder="Enter Policy Run Days" oninput="earnedPremiumCalc(this)" onkeyup="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
@ -1083,6 +1150,7 @@ function addHTMLInput(check) {
|
||||
$('.gpa_div_elements').show();
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
// $('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
$('.proposed_div').hide()
|
||||
@ -1116,8 +1184,10 @@ function addHTMLInput(check) {
|
||||
$('#proposed_tpa_'+ increment).select2();
|
||||
$('#policy_type_id_'+ increment).select2();
|
||||
|
||||
lead_type = $('#lead_type').val();
|
||||
// Initialize date pickers
|
||||
var policy_start_datePicker = flatpickr("#policy_start_date_" + increment, {
|
||||
if (lead_type == 1){
|
||||
var policy_start_datePicker = flatpickr("#policy_start_date_" + increment, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
onChange: function(selectedDates) {
|
||||
@ -1144,7 +1214,7 @@ function addHTMLInput(check) {
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
}
|
||||
});
|
||||
});}
|
||||
|
||||
var policy_end_datePicker = flatpickr("#policy_end_date_" + increment, {
|
||||
dateFormat: "d/m/Y",
|
||||
@ -1254,20 +1324,22 @@ function incurredClaimSum(input) {
|
||||
|
||||
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
console.log('policy_run_days', policy_run_days);
|
||||
|
||||
console.log('incurred claims '+incurred_claims);
|
||||
// Prevent division by zero in annualised claims calculation
|
||||
let annualised_claims = policy_run_days > 0 ? incurred_claims / policy_run_days * 365 : 0;
|
||||
console.log('annualised_claims', annualised_claims);
|
||||
let annualised_claims_roundoff = Math.round(annualised_claims);
|
||||
console.log('annualised_claims', annualised_claims_roundoff);
|
||||
|
||||
$('#annualised_claims_' + increment).val(annualised_claims);
|
||||
$('#annualised_claims_' + increment).val(annualised_claims_roundoff);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
// Prevent division by zero in incurred claim ratio calculation
|
||||
let incurred_claim_ratio = annualised_claims > 0 ? incurred_claims / annualised_claims : 0;
|
||||
console.log('incurred_claim_ratio', incurred_claim_ratio);
|
||||
let incurred_claim_ratio_roundoff = Math.round(incurred_claim_ratio);
|
||||
console.log('incurred_claim_ratio', incurred_claim_ratio_roundoff);
|
||||
|
||||
$('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio);
|
||||
$('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio_roundoff);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
@ -1276,9 +1348,10 @@ function incurredClaimSum(input) {
|
||||
|
||||
// Prevent division by zero in earned claims ratio calculation
|
||||
let earned_claims_ratio = earned_premium > 0 ? incurred_claims / earned_premium : 0;
|
||||
let earned_claims_ration_roundoff = Math.round(earned_claims_ratio);
|
||||
console.log('earned_claims_ratio', earned_claims_ratio);
|
||||
|
||||
$('#earned_claims_ratio_' + increment).val(earned_claims_ratio);
|
||||
$('#earned_claims_ratio_' + increment).val(earned_claims_ration_roundoff);
|
||||
}
|
||||
|
||||
function earnedPremiumCalc(input) {
|
||||
@ -1296,9 +1369,9 @@ function earnedPremiumCalc(input) {
|
||||
// Prevent division by zero and calculate earned premium
|
||||
let earned_premium = policy_run_days > 0 ? premium_at_inception / policy_run_days : 0;
|
||||
console.log('earned_premium', earned_premium);
|
||||
|
||||
let earned_premium_roundoff = Math.round(earned_premium);
|
||||
// Set the calculated value with two decimal places
|
||||
$('#earned_premium_' + increment).val(earned_premium.toFixed(2));
|
||||
$('#earned_premium_' + increment).val(earned_premium_roundoff);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
@ -1384,6 +1457,9 @@ $('#lead_type').change(function() {
|
||||
|
||||
if (value == 2) {
|
||||
|
||||
|
||||
$('.btnDiv').hide();
|
||||
|
||||
$('#renewalDiv').find('select, input').attr('required', 'required');
|
||||
$('#freshDiv').find('select, input').removeAttr('required');
|
||||
$('#renewalDiv').show();
|
||||
@ -1410,6 +1486,7 @@ $('#lead_type').change(function() {
|
||||
|
||||
} else {
|
||||
|
||||
$('.btnDiv').show();
|
||||
$('#renewalDiv').find('select, input').removeAttr('required');
|
||||
$('#freshDiv').find('select, input').attr('required', 'required');
|
||||
$('#renewalDiv').hide();
|
||||
@ -1432,7 +1509,7 @@ $('#lead_type').change(function() {
|
||||
if(value == 1){
|
||||
$('.freashDiv').hide()
|
||||
$('.renewalDiv').show()
|
||||
|
||||
$('.btnDiv').show();
|
||||
$('.emp_title').text('No of Employees')
|
||||
$('.depnd_title').text('No of Dependents')
|
||||
$('.total_title').text('Total Lives')
|
||||
@ -1568,4 +1645,13 @@ function getURLParamsForReport() {
|
||||
console.log('lead_id', lead_id); // Retain the log if necessary
|
||||
}
|
||||
|
||||
$('#policy_type_id').change(function() {
|
||||
console.log("policy type changed");
|
||||
var policy_type_id = $(this).val();
|
||||
if (policy_type_id == 2) {
|
||||
$('.freashDiv').show();
|
||||
} else {
|
||||
$('.freashDiv').hide(); // Optional: Hide when `policy_type_id` is not 2
|
||||
}});
|
||||
|
||||
</script>
|
||||
@ -435,10 +435,12 @@ $(document).ready(function(){
|
||||
let client_id = $(this).val();
|
||||
let client_type = $('#client_id option:selected').data('ct');
|
||||
|
||||
if(branch_list != '' && client_id != '') {
|
||||
if(branch_list[client_id] != '' && branch_list[client_id] != null && client_id != '') {
|
||||
console.log('branch_list', branch_list[client_id]);
|
||||
let data = branch_list[client_id];
|
||||
appendBranch(data);
|
||||
}else{
|
||||
toastr.warning("No Branch Found for the selected Client",'Warning');
|
||||
}
|
||||
|
||||
})
|
||||
@ -447,10 +449,12 @@ $(document).ready(function(){
|
||||
|
||||
let client_branch_id = $(this).val();
|
||||
|
||||
if(policy_list != '' && client_branch_id != '') {
|
||||
if(policy_list[client_branch_id] != '' && policy_list[client_branch_id] != null && client_branch_id != ''&& client_branch_id != null) {
|
||||
console.log('policy_list', policy_list[client_branch_id]);
|
||||
let data = policy_list[client_branch_id];
|
||||
appendRenewalPolicies(data);
|
||||
}else{
|
||||
toastr.warning("No Policies Found for the selected Branch",'Warning');
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user