diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index fcf5c373..e0a556db 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5065,25 +5065,60 @@ 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'); - $client_type = $this->request->getGet('client_type'); + $received_data = $this->request->getGet(); + $policy_no = trim($this->request->getGet('policy_no')); + $client_id = $this->request->getGet('client_id') ?? null; + $client_branch_id = $this->request->getGet('client_branch_id') ?? null; + $policy_type_id = $this->request->getGet('policy_type_id') ?? null; + $client_type = $this->request->getGet('client_type') ?? null; - $data = $this->policyTransactionModel + // Check in Policy Transaction (BDS) + $bds_count = $this->policyTransactionModel ->where('is_active', 1) ->where('action_type', 'inception') - ->where('policy_no', $policy_no) + ->where('TRIM(policy_no)', $policy_no) + ->where('policy_no IS NOT NULL AND policy_no <> ""') ->countAllResults(); - $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('policy_status', 1)->where('policy_no', trim($policy_no))->first(); + // Check in Enrollment (client_policy) + $client_policy_data = $this->clientPolicyModel + ->where('is_active', 1) + ->where('policy_status', 1) + ->where('TRIM(policy_no)', $policy_no) + ->first(); + + // Decide message + count + if ($bds_count > 0) { + + return $this->respond([ + 'status' => true, + 'message' => "This policy number is already linked to another policy in the BDS", + 'code' => 409, + 'data' => $bds_count, + 'received_data' => $received_data, + 'client_policy_id' => $client_policy_data['id'] ?? null + ], 200); + + } elseif (!empty($client_policy_data)) { + + return $this->respond([ + 'status' => true, + 'message' => "This policy number is already linked to another policy in the Enrollment", + 'code' => 409, + 'data' => 1, + 'received_data' => $received_data, + 'client_policy_id' => $client_policy_data['id'] + ], 200); - if ($data > 0) { - return $this->respond(['status' => true, 'message' => 'This policy number is already linked to another client', 'data' => $data, 'code' => 409, 'received_data' => $received_data, 'client_policy_id' => $client_policy_data['id'] ?? null], 200); } else { - return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data, 'client_policy_id' => $client_policy_data['id'] ?? null], 200); + + return $this->respond([ + 'status' => false, + 'message' => 'No Data Found', + 'code' => 404, + 'received_data' => $received_data, + 'client_policy_id' => null + ], 200); } } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index a2143b50..fad59045 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -5340,6 +5340,7 @@ class EmpDataServiceController extends BaseController 'co_share_type' => 1, 'co_share_per' => 100, 'standerd_bp_per' => $policy_type_data['ebp'], + 'pt_policy_issue_date' => $params['policy_issue_date'] ?? null, 'amount' => ($params['base_premium'] ?? 0) + ($params['gst'] ?? 0), ]; diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index a64e3fc3..88e2300e 100755 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -1988,8 +1988,10 @@ input:checked + .slider_blue::before { console.log(policy_no + '-' + policy_no.length); $.ajax({ - url: '' + policy_no, + // url: '' + policy_no, + url: '', type: "GET", + data : {policy_no : policy_no}, dataType: 'json', success: function (res) { console.log(res); diff --git a/app/Views/insurer_or_tpa_data.php b/app/Views/insurer_or_tpa_data.php index 33e34bf2..902e5419 100755 --- a/app/Views/insurer_or_tpa_data.php +++ b/app/Views/insurer_or_tpa_data.php @@ -101,13 +101,13 @@ - +
@@ -171,10 +171,10 @@ $(document).ready(function() { - // var policy_issue_datePicker = flatpickr("#policy_issue_date", { - // dateFormat: "d/m/Y", - // allowInput: false, - // }); + var policy_issue_datePicker = flatpickr("#policy_issue_date", { + dateFormat: "d/m/Y", + allowInput: false, + }); $('#insurer_or_tpa, #action_type').on('change', togglePolicyIssueDate); }); @@ -796,15 +796,15 @@ function togglePolicyIssueDate() { let insurer = $('#insurer_or_tpa').val(); let action = $('#action_type').val(); - // if (insurer === 'insurer' && action === 'import') { - // $('.policy_issue_date_row').show(); - // $('#policy_issue_date').attr('required', true); - // $('#policy_issue_date_label').html('Policy Issue Date *'); - // } else { - // $('.policy_issue_date_row').hide(); - // $('#policy_issue_date').removeAttr('required').val(''); - // $('#policy_issue_date_label').text('Policy Issue Date'); - // } + if (insurer === 'insurer' && action === 'import') { + $('.policy_issue_date_row').show(); + $('#policy_issue_date').attr('required', true); + $('#policy_issue_date_label').html('Policy Issue Date *'); + } else { + $('.policy_issue_date_row').hide(); + $('#policy_issue_date').removeAttr('required').val(''); + $('#policy_issue_date_label').text('Policy Issue Date'); + } } function fetchTpaIdFromTpa(){