From cf3547333d9b8c46ee8df413db5fbf4bf1432deb Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Sat, 30 Mar 2024 18:18:39 +0530 Subject: [PATCH] FIX_CLIENT_POLICY_NAME_ADD_POLICY_TYPE_NAME : AADHAVAN --- app/Controllers/EmployeeRestController.php | 32 ++++++++++++---------- app/Models/ClientPolicyModel.php | 7 ++++- app/Views/client_basic_info.php | 6 ++-- app/Views/client_policy.php | 7 +++-- public/assets/api.yaml | 3 -- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 973a5d3c..70abe646 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -497,11 +497,13 @@ class EmployeeRestController extends AdminController try { $file = $this->request->getFile('file'); $client_id = $this->request->getPost('client_id'); - // $client_id = $this->request->getJSON('client_id'); $policy_id = $this->request->getPost('policy_id'); - $employee_id = $this->request->getPost('employee_id'); - // $policy_id = $this->request->getJSON('policy_id'); + $token = $this->request->headers()['Auth']->getValue(); + $decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true); + + // get the employee id from token + $employee_id = $decodedPayload['id']; $client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->first(); @@ -586,18 +588,18 @@ class EmployeeRestController extends AdminController } $dataToInsert = []; $basic_cover_si= []; - if ($extra[9]) { - $new_array = []; - for ($i=0; $i < count($extra[9]); $i++) { - if ($sum_insured_amount_for_check_employee_2 != $extra[9][$i] || $sum_insured_amount_for_check_employee_1 != $extra[9][$i]) { - $new_array[] = $i+1; - } - } - if (count($new_array) > 0) { - $count =count($new_array); - return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "$count Employee Sum Insured is Not Match.. " , 'data' => $new_array], 200); - } - } + // if ($extra[9]) { + // $new_array = []; + // for ($i=0; $i < count($extra[9]); $i++) { + // if ($sum_insured_amount_for_check_employee_2 != $extra[9][$i] || $sum_insured_amount_for_check_employee_1 != $extra[9][$i]) { + // $new_array[] = $i+1; + // } + // } + // if (count($new_array) > 0) { + // $count =count($new_array); + // return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "$count Employee Sum Insured is Not Match.. " , 'data' => $new_array], 200); + // } + // } foreach ($extra['0'] as $index => $id) { $relation =''; if ($extra['5'][$index] === 'Mother' || $extra['5'][$index] === 'Father') { diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 2ebafcc9..01bc2a2c 100644 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -61,12 +61,14 @@ class ClientPolicyModel extends Model } public function getClientPolicyByClientId($client_id){ + return $this->db->table('client_policy') ->select('client_policy.*') ->select('insurers.name as insurer_name, insurers.short_name as insurer_short') ->select('tpa.name as tpa_name, tpa.short_name as tpa_short') - ->select('policies.name as policy_name') + ->select('policies.name as policy_name, policies.policy_type_id') + ->select('policy_type.policy_type as policy_type_name') ->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code') ->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code') ->join('insurers', 'insurers.id = client_policy.insurer_id') @@ -74,10 +76,13 @@ class ClientPolicyModel extends Model ->join('tpa', 'tpa.id = client_policy.tpa_id') ->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id') ->join('policies', 'policies.id = client_policy.policy_id') + ->join('policy_type', 'policy_type.id = policies.policy_type_id') ->where('client_policy.client_id', $client_id) ->get() ->getResult(); + + } public function getPolicyPremium($policy_id){ diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php index 9d562f2b..3f08c20a 100644 --- a/app/Views/client_basic_info.php +++ b/app/Views/client_basic_info.php @@ -105,13 +105,11 @@ input:checked + .slider:before {
- +
- +
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 9018586c..a4e893ab 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -194,12 +194,15 @@ if (policy_PrimaryKey !== '') { var policyTable = ''; var data = ; - data.forEach(function(item) { + // console.log("----------------------------"); + + // console.log(item); + policyTable += ` ${item.insurer_short} - ${item.insurer_branch_name} - ${item.policy_name} + ${item.policy_name} (${item.policy_type_name}) ${item.tpa_short} - ${item.tpa_branch_code} ${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)} ${checkDateStatus(item.policy_end_date, 1)} diff --git a/public/assets/api.yaml b/public/assets/api.yaml index 4d3e8f7e..d8159bab 100644 --- a/public/assets/api.yaml +++ b/public/assets/api.yaml @@ -175,9 +175,6 @@ paths: policy_id: type: integer description: policy_id - employee_id: - type: integer - description: employee_id file: type: string format: binary