Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
d0dbf35644
@ -418,12 +418,12 @@ class ClientController extends AdminController
|
||||
$data['client_id'] = $this->request->getPost('client_id');
|
||||
|
||||
|
||||
$data['insured'] = $this->request->getPost('insured');
|
||||
$data['no_of_lives'] = $this->request->getPost('no_of_lives');
|
||||
$data['policy_status'] = $this->request->getPost('policy_status');
|
||||
$data['no_of_employees'] = $this->request->getPost('no_of_employees');
|
||||
$data['earned_premium_date'] = change_date_format($this->request->getPost('earned_premium_date'), 'd-m-Y', 'Y-m-d');
|
||||
$data['claims_incurred_date'] = change_date_format($this->request->getPost('claims_incurred_date'), 'd-m-Y', 'Y-m-d'); $data['incurred_claims_ratio'] = $this->request->getPost('incurred_claims_ratio');
|
||||
$data['claims_incurred_date'] = change_date_format($this->request->getPost('claims_incurred_date'), 'd-m-Y', 'Y-m-d');
|
||||
$data['incurred_claims_ratio'] = $this->request->getPost('incurred_claims_ratio');
|
||||
$data['no_lives_at_inception'] = $this->request->getPost('no_lives_at_inception');
|
||||
$data['premium_paid_at_inception'] = $this->request->getPost('premium_paid_at_inception');
|
||||
$data['claims_experience_for_last_3_years'] = $this->request->getPost('claims_experience_for_last_3_years');
|
||||
@ -629,7 +629,7 @@ class ClientController extends AdminController
|
||||
$client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first();
|
||||
$insurer_id = $client_policy_data['insurer_id'];
|
||||
$polices = $this->policesModel->where(['insurer_id' => $insurer_id, 'is_active' => 1])->findAll();
|
||||
echo json_encode(array("status" => true , 'data' => $client_policy_data, 'policy' => $polices));
|
||||
echo json_encode(array("insurer_id" => $client_policy_data['insurer_id'], "status" => true , 'data' => $client_policy_data, 'policy' => $polices));
|
||||
}else{
|
||||
echo json_encode(array("status" => false));
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@ class ClientPolicyModel extends Model
|
||||
"insurer_branch_id",
|
||||
"tpa_id",
|
||||
"tpa_branch_id",
|
||||
"policy_type_id",
|
||||
|
||||
|
||||
"policy_start_date",
|
||||
"policy_end_date",
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
<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" id="policy_type_id" id="policy_type_id"/>
|
||||
<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">
|
||||
|
||||
@ -115,20 +115,34 @@ var policy_client = $('#policy_PrimaryKey').val();
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
//Configure Flatpicker for the policy start date datepicker.
|
||||
flatpickr("#start_date", {
|
||||
// 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",
|
||||
defaultDate: today,
|
||||
allowInput: false,
|
||||
onChange: function(selectedDates, dateStr, instance) {
|
||||
var endDate = new Date(selectedDates[0]);
|
||||
endDate.setFullYear(endDate.getFullYear() + 1);
|
||||
|
||||
endDatePicker.setDate(endDate);
|
||||
}
|
||||
});
|
||||
|
||||
//Configure Flatpicker for the policy end date datepicker.
|
||||
flatpickr("#end_date", {
|
||||
// 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: "today",
|
||||
defaultDate: endDate,
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
|
||||
$('#add_form').hide();
|
||||
$('.btnBack').hide();
|
||||
|
||||
@ -188,79 +202,81 @@ $(document).ready(function () {
|
||||
//for form submit using AJAX
|
||||
$("#policy_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
event.preventDefault();
|
||||
|
||||
policy_PrimaryKey = $('#client_id_policy').val();
|
||||
policy_client = $('#policy_PrimaryKey').val();
|
||||
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 ;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (res.status === false) {
|
||||
toastr.error('Policy Dose Not Create', 'Error');
|
||||
return;
|
||||
if (policy_PrimaryKey === '' && policy_client === '') {
|
||||
toastr.error('Client is required', 'Error');
|
||||
$('#insurer').val('');
|
||||
$('#tpa').val('');
|
||||
$('#policy').html('<option value="" selected>Select Policy</option>');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(res);
|
||||
var message = (policy_PrimaryKey === '') ? 'Policy Created successfully' : 'Policy Updated Successfully';
|
||||
toastr.success(message, 'Success');
|
||||
var isValid = $('#policy_form').parsley().validate();
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
|
||||
$('#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>
|
||||
<a data-id="${item.id}" class="btnPolicyEdit mdi mdi-lead-pencil" href="#" style="font-size:18px;"></a>
|
||||
<a data-id="${item.policy_id}" class="btnPolicyModel mdi mdi-book-open" href="#" data-toggle="modal" data-target="#bs-example-modal-lg" style="font-size:18px;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
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) {
|
||||
|
||||
if (res.status === false) {
|
||||
toastr.error('Policy Dose Not Create', 'Error');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(res);
|
||||
var message = (policy_PrimaryKey === '') ? 'Policy Created successfully' : 'Policy Updated Successfully';
|
||||
toastr.success(message, 'Success');
|
||||
|
||||
$('#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>
|
||||
<a data-id="${item.id}" class="btnPolicyEdit mdi mdi-lead-pencil" href="#" style="font-size:18px;"></a>
|
||||
<a data-id="${item.policy_id}" class="btnPolicyModel mdi mdi-book-open" href="#" data-toggle="modal" data-target="#bs-example-modal-lg" style="font-size:18px;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
$('#policy_table').append(policyTable);
|
||||
$('#add_form').hide();
|
||||
$('#table_list').show();
|
||||
$('.btnBack').hide();
|
||||
$('.btnAdd').show();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
$('#policy_table').append(policyTable);
|
||||
$('#add_form').hide();
|
||||
$('#table_list').show();
|
||||
$('.btnBack').hide();
|
||||
$('.btnAdd').show();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//To get th POLICY base on Insurer
|
||||
$('#insurer').change(function() {
|
||||
var id = $(this).val();
|
||||
var url = "<?= base_url("util/police-by-insurer/") ?>" + id;
|
||||
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)
|
||||
@ -281,13 +297,17 @@ $.ajax({
|
||||
|
||||
// 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{
|
||||
appendPolicyFormFields(2)
|
||||
appendPolicyFormFields(1);
|
||||
}else if (dataId >= 1){
|
||||
appendPolicyFormFields(2);
|
||||
}
|
||||
|
||||
console.log('second', $('#policy_type_id').val());
|
||||
});
|
||||
|
||||
|
||||
@ -295,16 +315,18 @@ $.ajax({
|
||||
$('body').on('click', '.btnPolicyEdit', function () {
|
||||
|
||||
var policy_form_action = '';
|
||||
var policy_id = $(this).data('id');
|
||||
console.log('1', policy_id)
|
||||
var policyId = $(this).attr('data-id');
|
||||
console.log('2', policyId)
|
||||
// var policy_id = $(this).data('id');
|
||||
// console.log('1', policy_id)
|
||||
var policy_id = $(this).attr('data-id');
|
||||
console.log('2', policy_id)
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("client/policy/list/") ?>' + policy_id,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
|
||||
console.log(res);
|
||||
|
||||
$('#policy_form_action').val('<?= base_url("client/policy/edit"); ?>');
|
||||
|
||||
@ -328,12 +350,13 @@ $.ajax({
|
||||
|
||||
if(res.data.policy_type_id == 1){
|
||||
appendPolicyFormFields(1, res.data);
|
||||
}else {
|
||||
}else if(res.data.policy_type_id >= 2) {
|
||||
appendPolicyFormFields(2, res.data);
|
||||
}
|
||||
|
||||
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);
|
||||
@ -345,7 +368,6 @@ $.ajax({
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function appendPolicyFormFields(policy_type, data = false){
|
||||
|
||||
var html = '';
|
||||
@ -358,24 +380,6 @@ $.ajax({
|
||||
|
||||
html = `
|
||||
<div id="GMC">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="insured">Insured<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? data.insured : ''}" type="text" class="form-control" placeholder="Enter insured " name="insured" id="insured" required>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
@ -396,6 +400,21 @@ $.ajax({
|
||||
</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">
|
||||
@ -405,7 +424,7 @@ $.ajax({
|
||||
</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 : ''}" type="text" class="form-control" placeholder="Enter Claims Ratio" name="incurred_claims_ratio" id="incurred_claims_ratio" required>
|
||||
<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>
|
||||
@ -420,19 +439,15 @@ $.ajax({
|
||||
|
||||
html = `
|
||||
<div class="form-row" id="GPA">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="insured">Insured<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? data.insured : ''}" type="text" class="form-control" placeholder="Enter insured " name="insured" id="insured" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<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-3">
|
||||
<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-3">
|
||||
<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>
|
||||
@ -457,6 +472,40 @@ $.ajax({
|
||||
});
|
||||
}
|
||||
|
||||
$('#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');
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user