FIX_POLICY_NO_IN_BDS ; RV

This commit is contained in:
VENKATESHWARAN 2025-06-24 11:53:42 +05:30
parent b10ddfb8cd
commit 015f0068de
2 changed files with 42 additions and 5 deletions

View File

@ -4223,24 +4223,46 @@ class ClientController extends AdminController
}
public function get_client_policy_data_using_policy_no()
{
{
$received_data = $this->request->getGet();
$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
->select("
client_policy.*,
policy_type.policy_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_end_date, '%d/%m/%Y') as policy_end_date
")
->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.is_active', 1)
->where('client_policy.policy_status', 1)
->first();
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 {
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);
}
}

View File

@ -3838,6 +3838,15 @@ $('#policy_no').change(function(){
var policy_no = $(this).val();
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();
console.log('$pt_id', $pt_id);
@ -3846,13 +3855,19 @@ $('#policy_no').change(function(){
$.ajax({
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no/');?>',
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',
success: function (res) {
console.log('get_client_policy_data_using_policy_no response', res)
if(res.status == true){
if(res.status == true && res.code == 409){
toastr.warning(res.message,'WARNING');
$('#policy_no').val("");
return;
}
if(res.status == true){
$('#ct_type').val(1);
$('#client_policy_id').val(res.data.id);
$('#policy_start_date').val(res.data.policy_start_date);