FIX_POLICY_NO_IN_BDS ; RV
This commit is contained in:
parent
b10ddfb8cd
commit
015f0068de
@ -4224,23 +4224,45 @@ class ClientController extends AdminController
|
|||||||
|
|
||||||
public function get_client_policy_data_using_policy_no()
|
public function get_client_policy_data_using_policy_no()
|
||||||
{
|
{
|
||||||
|
$received_data = $this->request->getGet();
|
||||||
$policy_no = $this->request->getGet('policy_no');
|
$policy_no = $this->request->getGet('policy_no');
|
||||||
|
$client_id = $this->request->getGet('client_id');
|
||||||
|
$client_branch_id = $this->request->getGet('client_branch_id');
|
||||||
|
$policy_type_id = $this->request->getGet('policy_type_id');
|
||||||
|
|
||||||
$data = $this->clientPolicyModel
|
$data = $this->clientPolicyModel
|
||||||
->select("
|
->select("
|
||||||
client_policy.*,
|
client_policy.*,
|
||||||
|
policy_type.policy_type,
|
||||||
clients.client_type,
|
clients.client_type,
|
||||||
|
clients.client_name,
|
||||||
DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
||||||
DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
|
DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
|
||||||
")
|
")
|
||||||
->join('clients', 'client_policy.client_id = clients.id')
|
->join('clients', 'client_policy.client_id = clients.id')
|
||||||
|
->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
|
||||||
->where('client_policy.policy_no', $policy_no)
|
->where('client_policy.policy_no', $policy_no)
|
||||||
->where('client_policy.is_active', 1)
|
->where('client_policy.is_active', 1)
|
||||||
|
->where('client_policy.policy_status', 1)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($data) {
|
if ($data) {
|
||||||
return $this->respond(['status' => true, 'data' => $data, 'code' => 200], 200);
|
if ($data['client_id'] == $client_id && $data['client_branch_id'] == $client_branch_id) {
|
||||||
|
|
||||||
|
if ($data['policy_type_id'] == $policy_type_id) {
|
||||||
|
return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200);
|
||||||
|
} else {
|
||||||
|
$policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first();
|
||||||
|
$message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.';
|
||||||
|
return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check';
|
||||||
|
return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404], 200);
|
return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3838,6 +3838,15 @@ $('#policy_no').change(function(){
|
|||||||
|
|
||||||
var policy_no = $(this).val();
|
var policy_no = $(this).val();
|
||||||
policy_no = policy_no.trim();
|
policy_no = policy_no.trim();
|
||||||
|
let client_id = $('#client_id').val()?.trim();
|
||||||
|
let client_branch_id = $('#client_branch_id').val()?.trim();
|
||||||
|
let policy_type_id = $('#policy_type_id').val()?.trim();
|
||||||
|
|
||||||
|
if (!client_id || !client_branch_id || !policy_type_id) {
|
||||||
|
toastr.warning('Please select the policy type, client and branch', "WARNING");
|
||||||
|
$('#policy_no').val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$pt_id = $('#policy_tranction_policy_number').val();
|
$pt_id = $('#policy_tranction_policy_number').val();
|
||||||
console.log('$pt_id', $pt_id);
|
console.log('$pt_id', $pt_id);
|
||||||
@ -3846,12 +3855,18 @@ $('#policy_no').change(function(){
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no/');?>',
|
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no/');?>',
|
||||||
type: "GET",
|
type: "GET",
|
||||||
data : { policy_no : policy_no },
|
data : { policy_no : policy_no, client_id : client_id, client_branch_id : client_branch_id, policy_type_id : policy_type_id},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
|
|
||||||
console.log('get_client_policy_data_using_policy_no response', res)
|
console.log('get_client_policy_data_using_policy_no response', res)
|
||||||
|
|
||||||
|
if(res.status == true && res.code == 409){
|
||||||
|
toastr.warning(res.message,'WARNING');
|
||||||
|
$('#policy_no').val("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(res.status == true){
|
if(res.status == true){
|
||||||
$('#ct_type').val(1);
|
$('#ct_type').val(1);
|
||||||
$('#client_policy_id').val(res.data.id);
|
$('#client_policy_id').val(res.data.id);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user