834 lines
38 KiB
PHP
834 lines
38 KiB
PHP
<div class="tab-pane fade" id="police-tab">
|
|
|
|
|
|
<div class="row float-right" style="padding-bottom: 10px; position: relative;right: 13px;">
|
|
<button type="button" id="BtnAdd" class="btn btn-primary waves-effect waves-light btnAdd btn-sm"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy</button>
|
|
</div>
|
|
|
|
<div class="table-responsive" id="table_list">
|
|
|
|
<table class="table table-borderless table-nowrap mb-0" id="table-client-policy">
|
|
<thead class="thead-light">
|
|
<tr>
|
|
<th>Insurer</th>
|
|
<th>Policy</th>
|
|
<th>TPA</th>
|
|
<th>Date</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="policy_table">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="row" id="add_form">
|
|
<div class="col-12">
|
|
<div class="card-body">
|
|
|
|
<div class="row float-right" style="position: relative; bottom: 20px; right: 13px;">
|
|
<button type="button" id="btnPolicyBack" class="btn btn-primary waves-effect waves-light btn-sm btnBack btn-sm"><span class="fa fa-list" aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<form role="form" class="parsley-examples" method="post" id="policy_form"
|
|
enctype="multipart/form-data">
|
|
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
|
<input type="hidden" name="PrimaryKey" id="policy_PrimaryKey" />
|
|
<input type="hidden" id="policy_form_action" />
|
|
<input type="hidden" name="policy_type_id" id="policy_type_id"/>
|
|
<input type="hidden" name="client_id" id="client_id_policy" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
|
|
<div class="form-group">
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="email">Insurer<span
|
|
class="text-danger">*</span></label>
|
|
<select class="form-control" id="insurer" name="insurer" required>
|
|
<option value="">Select Insurer</option>
|
|
<?php foreach($insurer as $value) { ?>
|
|
<option value="<?= $value['id'] . '-' . $value['insurer_id']?>"><?= $value['insurer_name'] . '-' . $value['branch_code'] ?></option>
|
|
<?php } ?>
|
|
</select>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="policy">Policies<span
|
|
class="text-danger">*</span></label>
|
|
<select class="form-control" id="policy" name="policy_id" required>
|
|
<option value="" selected>Select Policy</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="mobile">TPA<span
|
|
class="text-danger">*</span></label>
|
|
<select class="form-control" id="tpa" name="tpa" required>
|
|
<option value="">Select TPA</option>
|
|
<?php foreach($tpa as $value) { ?>
|
|
<option value="<?= $value['id']. '-' . $value['tpa_id'] ?>"><?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?></option>
|
|
<?php } ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="policy_start_date">Policy Start Date<span class="text-danger">*</span></label>
|
|
<input value="" type="text" class="form-control" placeholder="Enter Start Date " name="policy_start_date" id="start_date" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="policy_end_date">Policy End Date<span class="text-danger">*</span></label>
|
|
<input value="" type="text" class="form-control" placeholder="Enter End Date " name="policy_end_date" id="end_date" required>
|
|
</div>
|
|
<div class="form-group col-md-4" id="policy_status_field">
|
|
<label for="policy_status">Policy Status</label>
|
|
<input value="" type="text" class="form-control" placeholder="Policy Status" id="policy_status" readonly>
|
|
</div>
|
|
<div >
|
|
<label class="switch">
|
|
<input id="is_addon" type="checkbox" name="is_addon" <?= (isset($client['is_addon']) && $client['is_addon'] == 1) ? 'checked' : '' ?>>
|
|
<span class="slider round" style="height: 27px;"></span>
|
|
</label>
|
|
<label for="is_addon" style=" position: relative;bottom: 5px;">Is AddOn Policy</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- <hr> -->
|
|
|
|
<div id="policy_fields"></div>
|
|
</div>
|
|
|
|
|
|
<div class="form-group text-right m-b-0">
|
|
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
|
id="btnSubmit">Submit</button>
|
|
<button type="button" class="btn btn-secondary waves-effect btnBack"
|
|
id="btnBack">Cancel</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div> <!-- end col-->
|
|
</div>
|
|
</div>
|
|
<!-- end -->
|
|
|
|
<?php include('policy_grid.php'); ?>
|
|
<?php include('policy_gmc_terms.php'); ?>
|
|
<?php include('policy_gpa_terms.php'); ?>
|
|
|
|
<script>
|
|
|
|
var policy_PrimaryKey = $('#client_id_policy').val();
|
|
var policy_client = $('#policy_PrimaryKey').val();
|
|
|
|
$(document).ready(function () {
|
|
|
|
$('#policy_status_field').hide()
|
|
|
|
// Get today's date
|
|
var today = new Date();
|
|
|
|
// Initialize Flatpickr for the start date with today's date
|
|
var startDatePicker = flatpickr("#start_date", {
|
|
dateFormat: "d-m-Y",
|
|
defaultDate: today,
|
|
allowInput: false,
|
|
onChange: function(selectedDates, dateStr, instance) {
|
|
var endDate = new Date(selectedDates[0]);
|
|
endDate.setFullYear(endDate.getFullYear() + 1);
|
|
|
|
endDatePicker.setDate(endDate);
|
|
}
|
|
});
|
|
|
|
// Calculate the end date (today + 1 year)
|
|
var endDate = new Date(today);
|
|
endDate.setFullYear(endDate.getFullYear() + 1);
|
|
|
|
// Initialize Flatpickr for the end date with the calculated end date
|
|
var endDatePicker = flatpickr("#end_date", {
|
|
dateFormat: "d-m-Y",
|
|
defaultDate: endDate,
|
|
allowInput: false
|
|
});
|
|
|
|
|
|
$('#add_form').hide();
|
|
$('.btnBack').hide();
|
|
|
|
|
|
$('.btnAdd').click(function(){
|
|
$('#add_form').show();
|
|
$('#table_list').hide();
|
|
$('.btnBack').show();
|
|
$('.btnAdd').hide();
|
|
$('#insurer').val('');
|
|
$('#tpa').val('');
|
|
$('#start_date').val('');
|
|
$('#end_date').val('');
|
|
$('#policy').html('<option value="" selected>Select Policy</option>');
|
|
$('#is_addon').prop('checked', false);
|
|
$('#policy_form_action').val('<?= base_url("client/policy/create"); ?>');
|
|
|
|
})
|
|
|
|
|
|
$('.btnBack').click(function(){
|
|
|
|
$('#GMC').remove();
|
|
$('#GPA').remove();
|
|
$('#add_form').hide();
|
|
$('#table_list').show();
|
|
$('.btnBack').hide();
|
|
$('.btnAdd').show();
|
|
$('#insurer').val('');
|
|
$('#tpa').val('');
|
|
$('#start_date').val('');
|
|
$('#end_date').val('');
|
|
$('#policy').html('<option value="" selected>Select Policy</option>');
|
|
|
|
})
|
|
|
|
|
|
if (policy_PrimaryKey !== '') {
|
|
var policyTable = '';
|
|
var data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
|
|
|
|
data.forEach(function(item) {
|
|
policyTable += `
|
|
<tr>
|
|
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
|
<td>${item.policy_name}</td>
|
|
<td>${item.tpa_short} - ${item.tpa_branch_code}</td>
|
|
<td>${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)}</td>
|
|
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
|
<td>
|
|
<div class="btn-group dropdown">
|
|
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
|
<div class="dropdown-menu dropdown-menu-right">
|
|
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
|
<a href="#" data-id="${item.id}" id="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" data-toggle="modal" id="${item.policy_type_id}"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
|
<a href="#" data-id="${item.id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rac Rate</a>
|
|
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment</a>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
`;
|
|
});
|
|
|
|
$('#policy_table').append(policyTable);
|
|
}
|
|
|
|
|
|
$('#table-client-policy').DataTable({
|
|
paging: true ,
|
|
searching: false
|
|
});
|
|
|
|
|
|
});
|
|
|
|
/******** for form submit using AJAX *******/
|
|
$("#policy_form").submit(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
policy_PrimaryKey = $('#client_id_policy').val();
|
|
policy_client = $('#policy_PrimaryKey').val();
|
|
|
|
if (policy_PrimaryKey === '' && policy_client === '') {
|
|
toastr.error('Client is required', 'Error');
|
|
$('#insurer').val('');
|
|
$('#tpa').val('');
|
|
$('#policy').html('<option value="" selected>Select Policy</option>');
|
|
return;
|
|
}
|
|
|
|
var isValid = $('#policy_form').parsley().validate();
|
|
if (!isValid) {
|
|
console.log('Form is Empty', 'Warning');
|
|
return ;
|
|
}
|
|
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
|
|
var formData = new FormData($('#policy_form')[0]);
|
|
var policy_form_action = $('#policy_form_action').val();
|
|
|
|
$.ajax({
|
|
data: formData,
|
|
url: policy_form_action,
|
|
type: "POST",
|
|
dataType: 'json',
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(res) {
|
|
|
|
console.log(res);
|
|
|
|
if (res.status === false) {
|
|
toastr.error('Policy Dose Not Create', 'Error');
|
|
return;
|
|
}
|
|
|
|
if(res){
|
|
setTimeout(function() {
|
|
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
$('#add_form').hide();
|
|
$('#table_list').show();
|
|
$('.btnBack').hide();
|
|
$('.btnAdd').show();
|
|
var message = (policy_PrimaryKey === '') ? 'Policy Created successfully' : 'Policy Updated Successfully';
|
|
toastr.success(message, 'Success');
|
|
}, 1000);
|
|
}
|
|
|
|
|
|
$('#policy_table tr').remove();
|
|
var policyTable = '';
|
|
$.each(res.data, function(index, item) {
|
|
policyTable += `
|
|
<tr>
|
|
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
|
<td>${item.policy_name}</td>
|
|
<td>${item.tpa_short} - ${item.tpa_branch_code}</td>
|
|
<td>${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)}</td>
|
|
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
|
<td>
|
|
<div class="btn-group dropdown">
|
|
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
|
<div class="dropdown-menu dropdown-menu-right">
|
|
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
|
<a href="#" data-id="${item.id}" class="dropdown-item btnPolicyMaster" data-toggle="modal" id="${item.policy_type_id}"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
|
<a href="#" data-id="${item.id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rac Rate</a>
|
|
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment</a>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
`;
|
|
});
|
|
$('#policy_table').append(policyTable);
|
|
|
|
$('#insurer').val('');
|
|
$('#tpa').val('');
|
|
$('#start_date').val('');
|
|
$('#end_date').val('');
|
|
$('#policy').html('<option value="" selected>Select Policy</option>');
|
|
$('#is_addon').prop('checked', false);
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
setTimeout(function() {
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
if (xhr.status === 404) {
|
|
toastr.warning('Resource not found', 'Warning');
|
|
} else if (xhr.status === 500) {
|
|
toastr.warning('Internal server error', 'Warning');
|
|
} else {
|
|
toastr.warning('Unknown error occurred', 'Warning');
|
|
}
|
|
}, 1000);
|
|
}
|
|
});
|
|
});
|
|
|
|
/********* To get th POLICY base on Insurer *******/
|
|
$('#insurer').change(function() {
|
|
var id = $(this).val();
|
|
var parts = id.split('-');
|
|
var secondPart = parts[1];
|
|
var url = "<?= base_url("util/police-by-insurer/") ?>" + secondPart;
|
|
|
|
$.get(url, function(res) {
|
|
// res = JSON.parse(res)//
|
|
// console.log(res)
|
|
var OptionsHTML = '';
|
|
OptionsHTML += '<option value="" selected>Select Policy</option>';
|
|
$.each(res.data, function(index, item) {
|
|
OptionsHTML += '<option data-id="' + item.policy_type_id + '" value="' + item.id + '">' + item.name + '</option>';
|
|
});
|
|
|
|
$('#policy').html(OptionsHTML);
|
|
}).fail(function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
});
|
|
});
|
|
|
|
/********* set the Policy_Type_id for Form Submit *******/
|
|
$('#policy').change(function(){
|
|
|
|
var dataId = $(this).children('option:selected').attr('data-id');
|
|
// console.log('dataId', dataId)
|
|
$('#policy_type_id').val(dataId);
|
|
|
|
// if(dataId == 1){
|
|
// appendPolicyFormFields(1);
|
|
// }else if (dataId >= 1){
|
|
// appendPolicyFormFields(2);
|
|
// }
|
|
|
|
});
|
|
|
|
// get the client policy data for edit
|
|
$('body').on('click', '.btnPolicyEdit', function () {
|
|
|
|
var policy_form_action = '';
|
|
// var policy_id = $(this).data('id');
|
|
// console.log('1', policy_id)
|
|
var policy_id = $(this).attr('data-id');
|
|
// console.log('2', policy_id)
|
|
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
$.ajax({
|
|
url: '<?= base_url("client/policy/list/") ?>' + policy_id,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function (res) {
|
|
console.log(res)
|
|
|
|
setTimeout(function() {
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
}, 1000);
|
|
// console.log('clientPolicy : ', res);
|
|
$('#policy_form_action').val('<?= base_url("client/policy/edit"); ?>');
|
|
|
|
if (res.status === false) {
|
|
toastr.error(res.status);
|
|
return;
|
|
}
|
|
|
|
$('#add_form').show();
|
|
$('#table_list').hide();
|
|
$('.btnBack').show();
|
|
$('.btnAdd').hide();
|
|
|
|
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
|
|
$('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id);
|
|
$('#policy').val(res.data.policy_id);
|
|
$('#policy_type_id').val(res.data.policy_type_id);
|
|
$('#policy_PrimaryKey').val(res.data.id);
|
|
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
|
|
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
|
|
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
|
|
$('#policy_status_field').show();
|
|
|
|
if (res.data.is_addon == 1) {
|
|
$('#is_addon').prop('checked', true);
|
|
} else {
|
|
$('#is_addon').prop('checked', false);
|
|
}
|
|
|
|
/** do not delete this comment condition
|
|
|
|
// if(res.data.policy_type_id == 1){
|
|
// appendPolicyFormFields(1, res.data);
|
|
// }else if(res.data.policy_type_id >= 2) {
|
|
// appendPolicyFormFields(2, res.data);
|
|
// }
|
|
|
|
do not delete this comment condition **/
|
|
|
|
var policeOptionHTML = '';
|
|
$.each(res.policy, function(index, item) {
|
|
// console.log(item)
|
|
policeOptionHTML += '<option data-id="' + item.policy_type_id + '" value="' + item.id + '" ' + (res.data.policy_id === item.id ? 'selected="selected"' : '') + '>' + item.name + '</option>';
|
|
});
|
|
$('#policy').html(policeOptionHTML);
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
setTimeout(function() {
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
toastr.warning('Something Wrong!', 'warning');
|
|
}, 1000);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('body').on('click', '.btnOpenEnroll', function () {
|
|
|
|
var client_policy_id = $(this).attr('data-id');
|
|
var policy_id = $(this).attr('id');
|
|
var client_id = $('#client_id_policy').val()
|
|
|
|
|
|
// console.log('client_policy_id', client_policy_id);
|
|
|
|
if(client_policy_id){
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
}
|
|
|
|
$.ajax({
|
|
url: '<?php echo base_url('util/update-policy-status');?>',
|
|
type: 'GET',
|
|
data: {
|
|
client_policy_id : client_policy_id,
|
|
},
|
|
success: function(res) {
|
|
// console.log(res);
|
|
if(res) {
|
|
setTimeout(function() {
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
if(res.status === true){
|
|
toastr.success(res.message, 'Success');
|
|
}else if(res.status === false){
|
|
toastr.warning(res.message, 'Warning');
|
|
}
|
|
}, 1000);
|
|
}
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
setTimeout(function() {
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
if (xhr.status === 404) {
|
|
toastr.warning('Resource not found', 'Warning');
|
|
} else if (xhr.status === 500) {
|
|
toastr.warning('Internal server error', 'Warning');
|
|
} else {
|
|
toastr.warning('Unknown error occurred', 'Warning');
|
|
}
|
|
}, 1000);
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
function appendPolicyFormFields(policy_type, data = false){
|
|
|
|
var html = '';
|
|
var container = document.getElementById('policy_fields');
|
|
|
|
if(policy_type == 2){
|
|
|
|
$('#GMC').remove();
|
|
$('#GPA').remove();
|
|
|
|
html = `
|
|
<div id="GMC">
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-3">
|
|
<label for="earned_premium_date">Earned Premium Date<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? rearrangeDateFormat(data.earned_premium_date) : ''}" type="date" class="form-control" placeholder="Enter Earned Premium Date " name="earned_premium_date" id="earned_premium_date" required>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="earned_premium_amount">Earned Premium<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.earned_premium_amount : ''}" type="text" class="form-control" placeholder="Enter Earned Premium " name="earned_premium_amount" id="earned_premium_amount" required>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="claims_incurred_date">Claims Incurred Date<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? rearrangeDateFormat(data.claims_incurred_date) : ''}" type="date" class="form-control" placeholder="Enter Claims Incurred Date " name="claims_incurred_date" id="claims_incurred_date" required>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="claims_incurred_amount">Claims Incurred<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.claims_incurred_amount : ''}" type="text" class="form-control" placeholder="Enter Claims Incurred " name="claims_incurred_amount" id="claims_incurred_amount" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-3">
|
|
<label for="no_of_employees">No of Employees<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.no_of_employees : ''}" type="text" class="form-control" placeholder="Enter No of Employees" name="no_of_employees" id="no_of_employees" required>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="no_of_lives">No of Lives<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.no_of_lives : ''}" type="text" class="form-control" placeholder="Enter No of Lives " name="no_of_lives" id="no_of_lives" required>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="no_lives_at_inception">No Lives at Inception<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.no_lives_at_inception : ''}" type="text" class="form-control" placeholder="Enter No Lives at Inception " name="no_lives_at_inception" id="no_lives_at_inception" required>
|
|
</div>
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="premium_paid_at_inception">Premium paid at Inception<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.premium_paid_at_inception : ''}" type="text" class="form-control" placeholder="Enter Premium paid at Inception" name="premium_paid_at_inception" id="premium_paid_at_inception" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="incurred_claims_ratio">Incurred Claims Ratio<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.incurred_claims_ratio : '0'}" type="text" class="form-control" placeholder="Enter Claims Ratio" name="incurred_claims_ratio" id="incurred_claims_ratio" readonly required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="policy_status">Policy Status<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.policy_status : ''}" type="text" class="form-control" placeholder="Enter Policy Status " name="policy_status" id="policy_status" required>
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
}else if(policy_type == 1){
|
|
|
|
$('#GMC').remove();
|
|
$('#GPA').remove();
|
|
|
|
html = `
|
|
<div class="form-row" id="GPA">
|
|
<div class="form-group col-md-4">
|
|
<label for="no_of_employees">No of Employees<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.no_of_employees : ''}" type="text" class="form-control" placeholder="Enter No of Employees" name="no_of_employees" id="no_of_employees" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="policy_status">Policy Status<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.policy_status : ''}" type="text" class="form-control" placeholder="Enter Policy Status " name="policy_status" id="policy_status" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="claims_experience_for_last_3_years">Claims Experience for Last 3 Years<span class="text-danger">*</span></label>
|
|
<input value="${data !== false && data !== undefined && data !== '' ? data.claims_experience_for_last_3_years : ''}" type="text" class="form-control" placeholder="Enter Claims Experience for Last 3 Years " name="claims_experience_for_last_3_years" id="claims_experience_for_last_3_years" required>
|
|
</div>
|
|
</div>`;
|
|
}
|
|
|
|
container.insertAdjacentHTML('beforeend', html);
|
|
|
|
if(policy_type == 2){
|
|
//Configure Flatpicker for the earned_premium_date datepicker.
|
|
flatpickr("#earned_premium_date", {
|
|
dateFormat: "d-m-Y",
|
|
defaultDate: "today",
|
|
allowInput: false,
|
|
});
|
|
|
|
//Configure Flatpicker for the claims_incurred_date datepicker.
|
|
flatpickr("#claims_incurred_date", {
|
|
dateFormat: "d-m-Y",
|
|
defaultDate: "today",
|
|
allowInput: false
|
|
});
|
|
}
|
|
|
|
$('#earned_premium_amount').keyup(function(){
|
|
|
|
var PA = parseFloat($(this).val());
|
|
var CA = parseFloat($('#claims_incurred_amount').val());
|
|
// console.log('earned_premium_amount',PA)
|
|
// console.log('claims_incurred_amount',CA)
|
|
|
|
if (!isNaN(PA) && !isNaN(CA) && CA !== 0) {
|
|
var incurredClaimRatio = CA / PA;
|
|
// console.log(incurredClaimRatio)
|
|
$('#incurred_claims_ratio').val(incurredClaimRatio.toFixed(2));
|
|
} else {
|
|
$('#incurred_claims_ratio').val('0');
|
|
}
|
|
});
|
|
|
|
|
|
$('#claims_incurred_amount').keyup(function(){
|
|
|
|
var CA = $(this).val()
|
|
var PA = $('#earned_premium_amount').val()
|
|
// console.log('earned_premium_amount',PA)
|
|
// console.log('claims_incurred_amount',CA)
|
|
|
|
if (!isNaN(PA) && !isNaN(CA) && CA !== 0) {
|
|
var incurredClaimRatio = CA / PA;
|
|
// console.log(incurredClaimRatio)
|
|
$('#incurred_claims_ratio').val(incurredClaimRatio.toFixed(2));
|
|
} else {
|
|
$('#incurred_claims_ratio').val('0');
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
//for date convert to indian formate like this 'yyyy-mm-dd' to this 'dd-mm-yyyy'
|
|
function rearrangeDateFormat(inputDate) {
|
|
|
|
if(inputDate !== null){
|
|
var dateComponents = inputDate.split("-");
|
|
var rearrangedDate = dateComponents[2] + "-" + dateComponents[1] + "-" + dateComponents[0];
|
|
return rearrangedDate;
|
|
}else{
|
|
return '00-00-0000';
|
|
}
|
|
}
|
|
|
|
function checkDateStatus(inputDate, bg = false) {
|
|
|
|
var givenDate = new Date(inputDate);
|
|
var currentDate = new Date();
|
|
|
|
if(bg != false){
|
|
if (givenDate < currentDate) {
|
|
return `<span class="badge badge-danger">Expired</span>`;
|
|
} else {
|
|
return `<span class="badge badge-success">Active</span>`;
|
|
}
|
|
}else{
|
|
if (givenDate < currentDate) {
|
|
return `Expired`;
|
|
} else {
|
|
return `Active`;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
const numberWords = {
|
|
0: "Zero", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine",
|
|
10: "Ten", 11: "Eleven", 12: "Twelve", 13: "Thirteen", 14: "Fourteen", 15: "Fifteen", 16: "Sixteen", 17: "Seventeen", 18: "Eighteen", 19: "Nineteen",
|
|
20: "Twenty", 30: "Thirty", 40: "Forty", 50: "Fifty", 60: "Sixty", 70: "Seventy", 80: "Eighty", 90: "Ninety"
|
|
};
|
|
|
|
function convertNumberToWords(number) {
|
|
if (number === 0) {
|
|
return numberWords[number];
|
|
}
|
|
|
|
let word = '';
|
|
|
|
if (number >= 10000000) {
|
|
word += convertNumberToWords(Math.floor(number / 10000000)) + " Crore ";
|
|
number %= 10000000;
|
|
}
|
|
|
|
if (number >= 100000) {
|
|
word += convertNumberToWords(Math.floor(number / 100000)) + " Lakh ";
|
|
number %= 100000;
|
|
}
|
|
|
|
if (number >= 1000) {
|
|
word += convertNumberToWords(Math.floor(number / 1000)) + " Thousand ";
|
|
number %= 1000;
|
|
}
|
|
|
|
if (number >= 100) {
|
|
word += convertNumberToWords(Math.floor(number / 100)) + " Hundred ";
|
|
number %= 100;
|
|
}
|
|
|
|
if (number > 0) {
|
|
if (word !== '') {
|
|
word += "and ";
|
|
}
|
|
if (number <= 20) {
|
|
word += numberWords[number];
|
|
} else {
|
|
word += numberWords[Math.floor(number / 10) * 10] + " " + numberWords[number % 10];
|
|
}
|
|
}
|
|
return word.trim();
|
|
}
|
|
|
|
function convertCommaNumberToWords(input) {
|
|
let number;
|
|
if (input instanceof HTMLElement) {
|
|
const inputValue = input.value;
|
|
number = parseInt(inputValue.replace(/,/g, ''), 10);
|
|
var convert_word_value = convertNumberToWords(number);
|
|
|
|
if (input.nextElementSibling !== null) {
|
|
input.nextElementSibling.textContent = convert_word_value;
|
|
}
|
|
} else {
|
|
number = parseInt(input.replace(/,/g, ''), 10);
|
|
}
|
|
var convert_word_value = convertNumberToWords(number);
|
|
|
|
return convert_word_value;
|
|
}
|
|
|
|
function onlyNumbers(event){
|
|
var charcode;
|
|
charcode = event.which || event.keyCode;
|
|
if(charcode>= 48 && charcode <= 57)return true;
|
|
return false;
|
|
}
|
|
|
|
|
|
function formatNumber(input, maxLength) {
|
|
|
|
// console.log("input", input);
|
|
maxLength=16;
|
|
let value = input.value.replace(/\D/g, ''); // Remove non-numeric characters
|
|
|
|
// Limit the number of digits
|
|
value = value.slice(0, maxLength);
|
|
|
|
// Format the number with commas using Indian numbering system
|
|
value = Number(value).toLocaleString('en-IN');
|
|
input.value = value;
|
|
|
|
basicPayMultiple(input)
|
|
if (input.id == 'gpa_si') {
|
|
gpaSumInsureMultiplier();
|
|
}
|
|
convertCommaNumberToWords(input);
|
|
|
|
if (input.id == 'gpa_sum_si') {
|
|
gpaSumInsureMultiplier(input);
|
|
}
|
|
|
|
// if(input.id == 'basic_pay'){
|
|
// var inputNumber = input.value;
|
|
// if (inputNumber) {
|
|
// var result = convertCommaNumberToWords(inputNumber);
|
|
// $("#gpa_basic_pay_number_word").text(result);
|
|
// } else {
|
|
// $("#gpa_basic_pay_number_word").text("");
|
|
// }
|
|
// }else if(input.id == 'basic_gpa_si'){
|
|
// var inputNumber = input.value;
|
|
// if (inputNumber) {
|
|
// var result = convertCommaNumberToWords(inputNumber);
|
|
// $("#basic_gpa_si_number_word").text(result);
|
|
// } else {
|
|
// $("#basic_gpa_si_number_word").text("");
|
|
// }
|
|
// }else if(input.id == 'basic_gpa_premium'){
|
|
// var inputNumber = input.value;
|
|
// if (inputNumber) {
|
|
// var result = convertCommaNumberToWords(inputNumber);
|
|
// $("#basic_gpa_premium_number_word").text(result);
|
|
// } else {
|
|
// $("#basic_gpa_premium_number_word").text("");
|
|
// }
|
|
// }else if(input.id == 'gpa_si'){
|
|
// var inputNumber = input.value;
|
|
// if (inputNumber) {
|
|
// var result = convertCommaNumberToWords(inputNumber);
|
|
// $("#gpa_sum_si_number_word").text(result);
|
|
// } else {
|
|
// $("#gpa_sum_si_number_word").text("");
|
|
// }
|
|
// }else if(input.id == 'gpa_premium'){
|
|
// var inputNumber = input.value;
|
|
// if (inputNumber) {
|
|
// var result = convertCommaNumberToWords(inputNumber);
|
|
// $("#gpa_sum_premium_number_word").text(result);
|
|
// } else {
|
|
// $("#gpa_sum_premium_number_word").text("");
|
|
// }
|
|
// }
|
|
|
|
return ;
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
function removeClientPolicy(element) {
|
|
console.log(element);
|
|
}
|
|
|
|
</script>
|