FIX_CLIENT_POLICY_EDIT : RV

This commit is contained in:
VENKATESHWARAN 2024-06-25 17:36:38 +05:30
parent 40aadfe529
commit eff7f933f5
2 changed files with 67 additions and 54 deletions

View File

@ -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 $policyCount = $this->clientPolicyModel
->where('policy_type_id', $policy_type_id) ->where('policy_type_id', $policy_type_id)

View File

@ -40,6 +40,7 @@
<input type="hidden" name="PrimaryKey" id="policy_PrimaryKey" /> <input type="hidden" name="PrimaryKey" id="policy_PrimaryKey" />
<input type="hidden" id="policy_form_action" /> <input type="hidden" id="policy_form_action" />
<input type="hidden" name="policy_type_id" id="policy_type_id" /> <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'] : '' ?>" /> <input type="hidden" name="client_id" id="client_id_policy" value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<div class="form-group"> <div class="form-group">
@ -259,7 +260,6 @@
tpaValue = item.tpa_short + '-' + item.tpa_branch_code; tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
} }
policyTable += ` policyTable += `
<tr> <tr>
<td>${item.insurer_short} - ${item.insurer_branch_name}</td> <td>${item.insurer_short} - ${item.insurer_branch_name}</td>
@ -316,6 +316,8 @@
$('#policy_form_action').val('<?= base_url("client/policy/create"); ?>'); $('#policy_form_action').val('<?= base_url("client/policy/create"); ?>');
$('#policy_status_field').hide() $('#policy_status_field').hide()
$('#base_policy_id').hide(); $('#base_policy_id').hide();
$('#policy_PrimaryKey').val("");
$('#insurer_policy_id').val("");
$('#first').hide(); $('#first').hide();
@ -635,6 +637,7 @@
}); });
}); });
$(document).ready(function() { $(document).ready(function() {
@ -649,28 +652,35 @@
console.log('client_id', client_id) console.log('client_id', client_id)
console.log('branch_id', branch_id) console.log('branch_id', branch_id)
console.log('policy_type_id', dataId) console.log('policy_type_id', dataId)
console.log('client_policy_id', $('#policy_PrimaryKey').val())
$('#policy_type_id').val(dataId); $('#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) if (response.count > 0) {
//console.log(response.data) console.log('Policy already exist in the branch');
if(response.count > 0){
console.log('Policy already exist in the branch')
toastr.error('Policy already exist in the branch', 'Error'); toastr.error('Policy already exist in the branch', 'Error');
$('#policy').val('').change(); $('#policy').val('').change();
} }
console.log('outer') console.log('outer');
}).fail(function(xhr, status, error) { }).fail(function(xhr, status, error) {
console.error(xhr.responseText); console.error(xhr.responseText);
console.error(status, error); console.error(status, error);
}); });
}
} else {
console.log('Missing parameter(s): dataId, branch_id, or client_id');
}
if (dataId == 1) { if (dataId == 1) {
@ -741,7 +751,7 @@
dataType: 'json', dataType: 'json',
success: function(res) { success: function(res) {
//console.log('client_policy_res', res) console.log('client_policy_res', res)
setTimeout(function() { setTimeout(function() {
$('.loader').fadeOut(); $('.loader').fadeOut();
@ -774,6 +784,7 @@
$('#policy_type_id').val(res.data.policy_type_id); $('#policy_type_id').val(res.data.policy_type_id);
$('#policy_PrimaryKey').val(res.data.id); $('#policy_PrimaryKey').val(res.data.id);
$('#insurer_policy_id').val(res.data.policy_id);
$('#policy_no').val(res.data.policy_no); $('#policy_no').val(res.data.policy_no);
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)); $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
@ -1305,8 +1316,6 @@
}); });
} }
if ($(this).val() == 3) { if ($(this).val() == 3) {
toastr.warning('Please Change the Policy Terms after Submit the Policy!', 'INFO'); toastr.warning('Please Change the Policy Terms after Submit the Policy!', 'INFO');
} }
@ -1440,13 +1449,15 @@
contentType: false, contentType: false,
success: function(res) { success: function(res) {
//console.log(res) console.log(res)
setTimeout(function() { setTimeout(function() {
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
}, 500); }, 500);
if(res.status == true){
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id) $('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id)
.change(); .change();
$('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change(); $('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change();
@ -1490,6 +1501,8 @@
}, 1500); }, 1500);
} }
}
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
console.error(xhr.responseText); console.error(xhr.responseText);