diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 34b77d02..e9c22dbe 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -234,6 +234,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("preview-card/(:any)", "EmployeeController::previewTemplate/$1"); $routes->get("export-import-error-list/(:any)", "EmployeeController::errorListExportImport/$1"); $routes->get("has_policy_config_completed/(:any)", "EmployeeController::hasPolicyConfigCompleted/$1"); + $routes->get("get-client-branch/(:any)", "ClientController::getClientBranch/$1"); + $routes->get("get-client-details/(:any)", "ClientController::getClientAllDetailsByUsingClientID/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 5b210e39..e3f7b038 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -98,12 +98,13 @@ class ClientController extends AdminController public function index() { - $this->myLogger->logme('error','Client list function called'); $headerData['page_name'] = 'Client List'; $data['clientList'] = $this->clientModel->getCreatedByUserName(); $data['client_rm'] = $this->clientRMModel->getAllClientRM(); + // dd($data); + echo view('layout/header', $headerData); echo view('client_list', $data); echo view('layout/footer'); @@ -584,6 +585,19 @@ class ClientController extends AdminController $this->myLogger->logme('error','Client policy CREATE function called'); + $policy_id = $this->request->getPost('policy_id'); + $client_branch_id = $this->request->getPost('client_branch_id'); + + $policyCount = $this->clientPolicyModel + ->where('policy_id', $policy_id) + ->where('client_branch_id', $client_branch_id) + ->countAllResult(); + + if($policyCount > 0 ){ + $clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id')); + return $this->respond(['status' => 'policy_exist','code' => 200,'data' => $clientPoliceData, 'method' => 'CERATE'], 200); + } + $insurerValue = (string) $this->request->getPost('insurer'); list($insurerBranchId, $insurerId) = explode('-', $insurerValue); $client_id = $this->request->getPost('client_id'); @@ -623,6 +637,7 @@ class ClientController extends AdminController $data['base_policy'] = $this->request->getPost('base_policy'); $data['policy_status'] = 1; $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1; + $data['client_branch_id'] = $this->request->getPost('client_branch_id'); @@ -717,6 +732,8 @@ class ClientController extends AdminController $data['base_policy'] = $this->request->getPost('base_policy'); $data['policy_status'] = 1; $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1; + $data['client_branch_id'] = $this->request->getPost('client_branch_id'); + $policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first(); @@ -1707,4 +1724,330 @@ class ClientController extends AdminController return "File not found."; } } + + + public function getClientBranch($client_id){ + + $branchs = $this->clientBranchModel + ->select('*') + ->where('client_id',$client_id) + ->findAll(); + + return $this->respond(['status' => true,'code' => 200, 'data' => $branchs], 200); + + + } + + public function getClientAllDetailsByUsingClientID($client_id) + { + + $db = \Config\Database::connect(); + + $builder = $db->table('clients'); + $builder->select(' + policies.name as policy_name, + policy_type.policy_type, + insurers.name as insurer_name, + insurers.short_name as insurer_short_name, + tpa.name as tpa_name, + tpa.short_name as tpa_short_name, + client_policy.policy_terms, + + DATE_FORMAT(client_policy.policy_start_date, "%d-%b-%Y") as policy_start_date, + DATE_FORMAT(client_policy.policy_end_date, "%d-%b-%Y") as policy_end_date, + + CASE + WHEN client_policy.base_policy IS NULL THEN "Not Appear" + WHEN client_policy.base_policy = 0 THEN "Not Appear" + ELSE (SELECT policies.name + FROM client_policy AS base_client_policy + JOIN policies ON policies.id = base_client_policy.policy_id + WHERE base_client_policy.id = client_policy.base_policy) + END as base_policy_name, + + CASE + WHEN client_policy.is_addon = 1 THEN "Base Policy" + WHEN client_policy.is_addon = 2 THEN "SI Topup" + WHEN client_policy.is_addon = 3 THEN "Dependent Addon" + ELSE "n/a" + END as is_addon, + + CASE + WHEN client_policy.policy_status = 1 THEN "Active" + WHEN client_policy.policy_status = 0 THEN "Expired" + ELSE "n/a" + END as policy_status, + + CASE + WHEN client_policy.inception_type = 1 THEN "File Upload" + WHEN client_policy.inception_type = 2 THEN "Enrollment" + ELSE "n/a" + END as inception_type, + + CASE + WHEN client_policy.open_for_enrollment = 1 THEN "Open" + WHEN client_policy.open_for_enrollment = 0 THEN "Closed" + ELSE "n/a" + END as open_for_enrollment, + client_branch.branch_name + + ', false); + $builder->join('client_policy', 'client_policy.client_id = clients.id'); + $builder->join('client_branch', 'client_policy.client_branch_id = client_branch.id'); + $builder->join('policies', 'policies.id = client_policy.policy_id'); + $builder->join('policy_type', 'policy_type.id = policies.policy_type_id'); + $builder->join('insurers', 'insurers.id = client_policy.insurer_id'); + $builder->join('tpa', 'tpa.id = client_policy.tpa_id'); + $builder->where('clients.is_active', 1); + $builder->where('client_policy.is_active', 1); + $builder->where('policies.is_active', 1); + $builder->where('policy_type.is_active', 1); + $builder->where('client_policy.policy_status', 1); + $builder->where('clients.id', $client_id); + + $query = $builder->get(); + $client_policy = $query->getResultArray(); + + $gmc_keys = [ + "sum_insured" => "Sum Insured", + "family_floater" => "Family Floater", + "family_floaters" => "Family Floaters", + "member_count" => "Elders Count:", + "other_member_min_age" => "Min Age:", + "other_member_max_age" => "Min Age:", + "waiverofpreexistingdiseases" => "Waiver of Pre-existing Diseases", + "9monthwaitingperiodwaived" => "9-month waiting Period –waived", + "coverfromthedateofjoining" => "Cover from the date of Joining", + "waiverof1,2,3&4thyearexclusions" => "Waiver of 1, 2, 3 & 4th year Exclusions", + "waiverof30dayswaitingperiod" => "Waiver of 30 days waiting period", + "prehospitalizationcover" => "Pre Hospitalization Cover", + "congenitaldiseasesinternal" => "Congenital Diseases - Internal", + "copayzonewisecopay" => "Co-Pay/Zone wise Co Pay", + "bioabsorbablestenttoriclensmultifocallens" => "Bio absorbable stent / Toric lens/ Multi Focal lens", + "roomrentlimit" => "Room Rent Limit", + "proportionatedeductionclause" => "Proportionate Deduction Clause", + "nursingallowance" => "Nursing Allowance", + "ailmentcapping" => "Ailment capping", + "ambulancecharges" => "Ambulance Charges", + "airambulance" => "Air Ambulance", + "familytransportationbenefit" => "Family Transportation Benefit", + "reasonableandcustomarycharges" => "Reasonable and Customary Charges", + "daycaretreatment" => "Day Care Treatment", + "ayudhtreatmentcover" => "AYUSH treatment cover", + "armdcovered" => "ARMD Covered", + "suminsuredenhancement" => "Sum Insured enhancement", + "automaticsuminsuredreinstatement" => "Automatic Sum Insured reinstatement", + "additionalsicknessbenefit" => "Additional Sickness Benefit", + "lasiksurgery" => "Lasik Surgery", + "midterminclusion" => "Mid Term inclusion", + "capd" => "CAPD", + "organdonorexpenses" => "Organ donor expenses", + "moderntreatmentsasperirdai" => "Modern treatments as per IRDAI", + "Wellness" => "Wellness", + "days_of_discharge" => "Claim Intimation Clause", + "days_from_dod" => "Claim Submission", + "cataract" => "Cataract" + ]; + + $gpa_keys = [ + "sumInsured2" => "Sum Insured", + "totalSumInsured" => "Total Sum Assured", + "self" => "Self", + "self_min_age" => "Min Age", + "self_max_age" => "Max Age", + "accidentalDeathBenefit" => "Accidental Death Benefit", + "permanentTotalDisablement" => "Permanent Total Disablement", + "permanentPartialDisablement" => "Permanent Partial Disablement", + "temporaryTotalDisablementBenefit" => "Temporary Total Disablement benefit", + "accidentalHospitalizationExpenses" => "Accidental Hospitalization Expenses", + "childrenEducationWelfareFund" => "Children Education Welfare Fund", + "compassionateVisitExpenses" => "Compassionate Visit Expenses", + "compassionateVisitExpensesData" => "Compassionate Visit Expenses Data", + "brokenBoneExpenses" => "Broken Bone Expenses", + "brokenBoneExpensesData" => "Broken Bone Expenses Data", + "ambulanceCharges" => "Ambulance charges", + "ambulanceChargesData" => "Ambulance charges Data", + "burnExpenses" => "Burn Expenses", + "burnExpensesData" => "Burn Expenses Data", + "carriageOfDeadBody" => "Carriage of Dead Body", + "carriageOfDeadBodyData" => "Carriage of Dead Body Data", + "animalSnakeInsectBite" => "Animal/Snake/Insect bite", + "terrorism" => "Terrorism", + "worldwideCover" => "Worldwide Cover" + ]; + + + + + foreach ($client_policy as $key => $value) { + + $policy_terms = json_decode($value['policy_terms'], true); + + $mapping = $gmc_keys; + if ($value['policy_type'] == 'GPA') { + $mapping = $gpa_keys; + } + + $client_policy[$key]['policy_terms'] = $this->transformArray($policy_terms, $mapping); + } + + + + + $data['client_policy'] = $client_policy; + + + + + $data['client_branch'] = $this->clientModel + + ->select(' + + client_branch.branch_name, + client_branch.branch_code, + client_branch.city, + level_contacts.name as hr_name, + level_contacts.designation, + level_contacts.mobile, + level_contacts.email + ') + ->join('client_branch', 'client_branch.client_id = clients.id') + ->join('level_contacts', 'level_contacts.ref_id = client_branch.id') + ->where('clients.is_active', 1) + ->where('client_branch.is_active', 1) + ->where('level_contacts.is_active', 1) + ->where('level_contacts.contact_type', 'client') + ->where('clients.id', $client_id) + ->get()->getResultArray(); + + + $data['client'] = $this->clientModel + ->select('clients.*, states.state as state') + ->join('states', 'states.id = clients.state') + ->where('clients.id', $client_id)->first(); + + + $client_rm = $this->clientRMModel + ->select('client_rm.*, user_profiles.first_name as user_name') + ->join('user_profiles', 'user_profiles.id = client_rm.user_id') + ->where('client_id', $client_id)->get()->getResultArray(); + + + $account_managers = []; + $managers = []; + $heads = []; + + foreach ($client_rm as $key => $value) { + if ($value['level'] == 3) { + $account_managers[] = $value['user_name']; + } elseif ($value['level'] == 2) { + $managers[] = $value['user_name']; + } elseif ($value['level'] == 1) { + $heads[] = $value['user_name']; + } + } + + $data['account_managers'] = $account_managers; + $data['managers'] = $managers; + $data['heads'] = $heads; + + // dd($data); + //$this->loadLayout('client_info', $data); + + + $html = view('client_info', $data); + return $this->respond(['status' => true,'code' => 200, 'data' => $html], 200); + + } + + + +public function transformArray($data, $mapping) { + + // dd($data); + $transformedData = []; + + if (!is_array($data)) { + return json_encode($transformedData, JSON_PRETTY_PRINT); + } + + foreach ($data as $key => $value) { + if ($key == 'family_floaters') { + $transformedData[$key] = $this->transformFamilyFloaters($value, $data); + }else if (array_key_exists($key, $mapping)) { + $transformedData[$mapping[$key]] = $value; + }else if($key == 'special_condition_label'){ + + foreach ($value as $key => $value) { + $transformedData[$value] = $data['special_condition_input'][$key]; + } + + }else if($key == 'gpa_special_condition_label'){ + + foreach ($value as $key => $value) { + $transformedData[$value] = $data['gpa_special_condition_input'][$key]; + } + + }else if($key == 'age_ratio'){ + + if(isset($data['sumInsured2'])){ + + $transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")"; + } + + + }else { + $transformedData[$key] = $value; + } + } + + return json_encode($transformedData, JSON_PRETTY_PRINT); +} + + +public function transformFamilyFloaters($familyFloaters, $json) { + $result = []; + + $min = $json['age_ratio']['self']; + $max = $json['age_ratio']['self']; + + $spouse_min = $json['age_ratio']['spouse']; + $spouse_max = $json['age_ratio']['spouse']; + + $child_min = $json['age_ratio']['child']; + $child_max = $json['age_ratio']['child']; + + $elders_min = $json['age_ratio']['elders']; + $elders_max = $json['age_ratio']['elders']; + + foreach ($familyFloaters as $key => $value) { + if ($value !== 0) { + switch ($key) { + case 'self': + $result[] = "Self (Min: {$min['min']}, Max: {$max['max']})"; + break; + case 'spouse': + $result[] = "Spouse (Min: {$spouse_min['min']}, Max: {$spouse_max['max']})"; + break; + case 'childrens': + $result[] = "Children(s) - $value (Min: {$child_min['min']}, Max: {$child_max['max']})"; + break; + case 'parents': + $result[] = "Parent(s) - $value (Min: {$elders_min['min']}, Max: {$elders_max['max']})"; + break; + case 'parents-in-law': + $result[] = "Parents-in-Law - $value (Min: {$elders_min['min']}, Max: {$elders_max['max']})"; + break; + case 'either-parents-pil': + $result[] = "Either Parents Nor Parents-in-Law - $value (elders_min: {$elders_min['min']}, Max: {$elders_max['max']})"; + break; + } + } + } + + return implode(", ", $result); +} + + + } \ No newline at end of file diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 4cdd36b5..b9cd0ae1 100644 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -41,7 +41,8 @@ class ClientPolicyModel extends Model "Is_active", "date_of_exit", "reason_for_exit", - "policy_no" + "policy_no", + "client_branch_id" ]; public function getClientPolicyById($id){ diff --git a/app/Views/UserList.php b/app/Views/UserList.php index a4d5afdc..bb51b99d 100644 --- a/app/Views/UserList.php +++ b/app/Views/UserList.php @@ -42,7 +42,7 @@ table.dataTable tbody td {
-

User List

+

User List

diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php index 335818bf..9e73bbd1 100644 --- a/app/Views/batch_list.php +++ b/app/Views/batch_list.php @@ -8,12 +8,12 @@ } -
+
-

Batch List

+

Batch List

@@ -54,7 +54,7 @@ - + @@ -104,7 +104,8 @@
- +
+
\ No newline at end of file diff --git a/app/Views/client_list.php b/app/Views/client_list.php index d6c876a2..4548631a 100644 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -7,6 +7,15 @@ table.dataTable tbody td { padding: 4px 4px !important; } + +table.dataTable thead th { + padding: 4px 4px !important; +} + +.col-12{ + + max-width: 98% !important; +}
@@ -15,9 +24,9 @@ table.dataTable tbody td {
-

Client List

+

Client List

- @@ -33,8 +42,8 @@ table.dataTable tbody td { - - client_name; ?> ( short_name; ?> ) + + client_name; ?> ( short_name; ?> ) @@ -66,10 +75,10 @@ table.dataTable tbody td {
- - - - + +
+ + \ No newline at end of file diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index 9ff286b9..267f3029 100644 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -41,7 +41,7 @@ body {
-

Client Onboarding

+

Client Onboarding

"> diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index e66f59b0..bb6e8294 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -2,7 +2,8 @@
- +
@@ -29,7 +30,9 @@
- +

@@ -39,22 +42,34 @@ - +
+ +
+ + +
+ +
@@ -84,8 +99,8 @@
@@ -94,19 +109,24 @@ @@ -117,7 +137,8 @@ - +
@@ -125,8 +146,10 @@
- - + +
@@ -140,149 +163,104 @@ \ No newline at end of file diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 24e24853..2e3be7b9 100644 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -28,7 +28,7 @@
-

Employees

+

Employees

diff --git a/app/Views/endorsement_list.php b/app/Views/endorsement_list.php index 3cac7546..d10d042f 100644 --- a/app/Views/endorsement_list.php +++ b/app/Views/endorsement_list.php @@ -80,7 +80,7 @@ table.dataTable tbody td {
-

Endorsement List

+

Endorsement List

diff --git a/app/Views/file_list.php b/app/Views/file_list.php index b4c0788f..b657273b 100644 --- a/app/Views/file_list.php +++ b/app/Views/file_list.php @@ -14,7 +14,7 @@
-

Files

+

Files

diff --git a/app/Views/insurer_list.php b/app/Views/insurer_list.php index 7a2f48a0..9a24b1de 100644 --- a/app/Views/insurer_list.php +++ b/app/Views/insurer_list.php @@ -4,7 +4,7 @@
-

Insurer List

+

Insurer List

" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">ADD diff --git a/app/Views/insurer_onboarding.php b/app/Views/insurer_onboarding.php index f7520d25..359543d9 100644 --- a/app/Views/insurer_onboarding.php +++ b/app/Views/insurer_onboarding.php @@ -36,7 +36,7 @@ body {
-

Insurer

+

Insurer

" > diff --git a/app/Views/kyc_list.php b/app/Views/kyc_list.php index 3f85daf5..a4bb712a 100644 --- a/app/Views/kyc_list.php +++ b/app/Views/kyc_list.php @@ -4,7 +4,7 @@
-

KYC List

+

KYC List

" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">ADD diff --git a/app/Views/kyc_onboarding.php b/app/Views/kyc_onboarding.php index 0db36ce1..412331ba 100644 --- a/app/Views/kyc_onboarding.php +++ b/app/Views/kyc_onboarding.php @@ -36,7 +36,7 @@ body {
-

KYC Entity Type

+

KYC Entity Type

" > diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 75127344..9e514a8a 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -295,7 +295,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').fadeOut('slow'); - }, 2000); + }, 1000); }); diff --git a/app/Views/policy_type_list.php b/app/Views/policy_type_list.php index 8fb7dae0..3bea931d 100644 --- a/app/Views/policy_type_list.php +++ b/app/Views/policy_type_list.php @@ -4,7 +4,7 @@
-

Policy Type List

+

Policy Type List

" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">ADD diff --git a/app/Views/policy_type_onboarding.php b/app/Views/policy_type_onboarding.php index f1c3075d..6cbb7ad0 100644 --- a/app/Views/policy_type_onboarding.php +++ b/app/Views/policy_type_onboarding.php @@ -36,7 +36,7 @@ body {
-

Policy Type

+

Policy Type

"> diff --git a/app/Views/tpa_list.php b/app/Views/tpa_list.php index d86a8506..cdba3ab7 100644 --- a/app/Views/tpa_list.php +++ b/app/Views/tpa_list.php @@ -4,7 +4,7 @@
-

TPA List

+

TPA List

" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">ADD diff --git a/app/Views/tpa_onboarding.php b/app/Views/tpa_onboarding.php index 1e14dabe..2d6196aa 100644 --- a/app/Views/tpa_onboarding.php +++ b/app/Views/tpa_onboarding.php @@ -36,7 +36,7 @@ body {
-

TPA

+

TPA