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 {