FIX_CLIENT_POLICY_EDIT : RV
This commit is contained in:
parent
40aadfe529
commit
eff7f933f5
@ -2206,7 +2206,7 @@ class ClientController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
public function checkPolicyType($client_policy_id, $policy_type_id, $client_branch_id, $client_id){
|
||||
public function checkPolicyType($policy_type_id, $client_branch_id, $client_id){
|
||||
|
||||
$policyCount = $this->clientPolicyModel
|
||||
->where('policy_type_id', $policy_type_id)
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
<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" id="insurer_policy_id" />
|
||||
<input type="hidden" name="client_id" id="client_id_policy" value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
|
||||
<div class="form-group">
|
||||
|
||||
@ -259,7 +260,6 @@
|
||||
tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
|
||||
}
|
||||
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
@ -316,6 +316,8 @@
|
||||
$('#policy_form_action').val('<?= base_url("client/policy/create"); ?>');
|
||||
$('#policy_status_field').hide()
|
||||
$('#base_policy_id').hide();
|
||||
$('#policy_PrimaryKey').val("");
|
||||
$('#insurer_policy_id').val("");
|
||||
|
||||
|
||||
$('#first').hide();
|
||||
@ -635,6 +637,7 @@
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
@ -649,28 +652,35 @@
|
||||
console.log('client_id', client_id)
|
||||
console.log('branch_id', branch_id)
|
||||
console.log('policy_type_id', dataId)
|
||||
console.log('client_policy_id', $('#policy_PrimaryKey').val())
|
||||
|
||||
|
||||
|
||||
$('#policy_type_id').val(dataId);
|
||||
|
||||
var url = '<?php echo base_url('util/check_policy_type/') ?>' + id + '/' + dataId + '/' + branch_id + '/' + client_id
|
||||
var url = '<?php echo base_url('util/check_policy_type/') ?>' + dataId + '/' + branch_id + '/' + client_id;
|
||||
|
||||
$.get(url, function(response){
|
||||
if (dataId && branch_id && client_id) { // Check if all parameters exist
|
||||
if ($('#policy_PrimaryKey').val() == "" || id != $('#insurer_policy_id').val()) {
|
||||
$.get(url, function(response) {
|
||||
console.log(response);
|
||||
console.log(response.count);
|
||||
|
||||
console.log(response)
|
||||
//console.log(response.data)
|
||||
if (response.count > 0) {
|
||||
console.log('Policy already exist in the branch');
|
||||
toastr.error('Policy already exist in the branch', 'Error');
|
||||
$('#policy').val('').change();
|
||||
}
|
||||
console.log('outer');
|
||||
|
||||
if(response.count > 0){
|
||||
console.log('Policy already exist in the branch')
|
||||
toastr.error('Policy already exist in the branch', 'Error');
|
||||
$('#policy').val('').change();
|
||||
}).fail(function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
});
|
||||
}
|
||||
console.log('outer')
|
||||
|
||||
|
||||
}).fail(function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
});
|
||||
} else {
|
||||
console.log('Missing parameter(s): dataId, branch_id, or client_id');
|
||||
}
|
||||
|
||||
|
||||
if (dataId == 1) {
|
||||
@ -741,7 +751,7 @@
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
//console.log('client_policy_res', res)
|
||||
console.log('client_policy_res', res)
|
||||
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
@ -774,6 +784,7 @@
|
||||
|
||||
$('#policy_type_id').val(res.data.policy_type_id);
|
||||
$('#policy_PrimaryKey').val(res.data.id);
|
||||
$('#insurer_policy_id').val(res.data.policy_id);
|
||||
$('#policy_no').val(res.data.policy_no);
|
||||
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
|
||||
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
|
||||
@ -1305,8 +1316,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($(this).val() == 3) {
|
||||
toastr.warning('Please Change the Policy Terms after Submit the Policy!', 'INFO');
|
||||
}
|
||||
@ -1440,54 +1449,58 @@
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
//console.log(res)
|
||||
console.log(res)
|
||||
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 500);
|
||||
|
||||
if(res.status == true){
|
||||
|
||||
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id)
|
||||
.change();
|
||||
$('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change();
|
||||
$('#policy_no').val(res.data.policy_no).change();
|
||||
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date))
|
||||
.change();
|
||||
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change();
|
||||
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id)
|
||||
.change();
|
||||
$('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change();
|
||||
$('#policy_no').val(res.data.policy_no).change();
|
||||
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date))
|
||||
.change();
|
||||
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change();
|
||||
|
||||
var policeOptionHTML = '';
|
||||
$policy_type_value = $('#policy_type').val();
|
||||
$.each(res.policy, function(index, item) {
|
||||
var policeOptionHTML = '';
|
||||
$policy_type_value = $('#policy_type').val();
|
||||
$.each(res.policy, function(index, item) {
|
||||
|
||||
// //console.log(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>';
|
||||
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);
|
||||
$('#policy').html(policeOptionHTML);
|
||||
|
||||
if (dataId == 3 || policy_type == 1) {
|
||||
if (dataId == 3 || policy_type == 1) {
|
||||
|
||||
// //console.log('step 1')
|
||||
// //console.log('step 1')
|
||||
|
||||
setTimeout(function() {
|
||||
// //console.log('step 2')
|
||||
var $option = $('#policy').find('option[data-id="3"]');
|
||||
if ($option.length > 0) {
|
||||
// //console.log('step 3')
|
||||
$option.prop('selected', true).change();
|
||||
} else {
|
||||
// //console.log('step 4');
|
||||
toastr.warning(
|
||||
'The insurer does not have a GMC-Parents policy.',
|
||||
'Warning');
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
// //console.log('step 2')
|
||||
var $option = $('#policy').find('option[data-id="3"]');
|
||||
if ($option.length > 0) {
|
||||
// //console.log('step 3')
|
||||
$option.prop('selected', true).change();
|
||||
} else {
|
||||
// //console.log('step 4');
|
||||
toastr.warning(
|
||||
'The insurer does not have a GMC-Parents policy.',
|
||||
'Warning');
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user