diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 73ce3697..9567f9a7 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -213,7 +213,7 @@ $routes->group("/master", ["filter" => "authMVC"], function ($routes) { $routes->post("create", "MasterController::createCDMasterData"); $routes->post("edit", "MasterController::editCDMasterData"); $routes->get("list/(:any)", "MasterController::getCDMasterDataByID/$1"); - // $routes->get("remove/(:any)", "MasterController::policyTypeRemove/$1"); + $routes->get("remove/(:any)", "MasterController::removeCDMaster/$1"); }); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 02269a95..2a3e5782 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -301,9 +301,9 @@ class ClientController extends AdminController $editData['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $id)->findAll(); $editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); $editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); - // dd('Hi'); + $editData['client_branch']['role'] = get_role_id(); $clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id); - // dd($this->clientPolicyModel->getLastQuery()); + foreach ($clientPoliceData as $key => $value) { $clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date)); @@ -311,12 +311,10 @@ class ClientController extends AdminController } $editData['client_policy'] = $clientPoliceData; - - $editData['notification'] =$this->notificationModel->select('template_name,enabled')->where('client_id',$id)->findAll(); $editData['placeHolders'] = ['member_name','nhance_logo','tpa_id','ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; - + // dd($editData); echo view('layout/header', $headerData); echo view('client_onboarding', $editData); echo view('layout/footer'); @@ -565,6 +563,7 @@ class ClientController extends AdminController if($insert){ $branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll(); + $branchData['role'] = get_role_id(); return $this->respond(['status' => true,'code' => 200,'data' => $branchData], 200); }else{ return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 04f1e336..5d6ec3b9 100644 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1123,13 +1123,7 @@ class MasterController extends AdminController public function CDMasterList() { - $data['CD_Master_Data'] = $this->CDMasterModel - ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name as insurer_name, user_profiles.first_name as user_name') - ->join('clients', 'clients.id = cd_master.client_id') - ->join('insurers', 'insurers.id = cd_master.insurer_id') - ->join('user_profiles', 'user_profiles.id = cd_master.created_by') - ->where('cd_master.is_active', 1) - ->findAll(); + $data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList(); $data['insurers'] = $this->insurerModel->findAll(); $data['clients'] = $this->clientModel->findAll(); $this->loadLayout('cd_master_list', $data); @@ -1217,4 +1211,18 @@ class MasterController extends AdminController } } + + public function removeCDMaster($id){ + + $this->myLogger->logme('error','CDMaster Remove function called'); + $data['updated_by'] = get_session_userid(); + $data['is_active'] = 0; + $update = $this->CDMasterModel->where('id', $id)->set($data)->update(); + if($update){ + return $this->respond(['status' => true,'code' => 200], 200); + }else{ + return $this->respond(['status' => false,'code' => 404], 200); + } + } + } \ No newline at end of file diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 2dbcb1ce..87945e48 100644 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -239,3 +239,12 @@ if (!function_exists('get_username')) { } +if (!function_exists('get_role_id')) { + function get_role_id() { + + $role_id = get_session_userdata()->role; + return $role_id; + } +} + + diff --git a/app/Models/CDMasterModel.php b/app/Models/CDMasterModel.php index 491d1007..0e5c39a1 100644 --- a/app/Models/CDMasterModel.php +++ b/app/Models/CDMasterModel.php @@ -61,4 +61,26 @@ class CDMasterModel extends Model return $data; } + public function getCDMasterList(){ + + $query = $this->db->table('cd_master') + ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count') + ->join('clients', 'clients.id = cd_master.client_id') + ->join('insurers', 'insurers.id = cd_master.insurer_id') + ->join('user_profiles', 'user_profiles.id = cd_master.created_by') + ->join( + '(SELECT cd_master.cd_ac_no, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count + FROM cd_master + JOIN client_policy ON client_policy.cd_ac_no = cd_master.cd_ac_no + GROUP BY cd_master.cd_ac_no) AS cd_ac_counts', + 'cd_ac_counts.cd_ac_no = cd_master.cd_ac_no', + 'left' + ) + ->where('cd_master.is_active', 1) + ->get(); + + $result = $query->getResultArray(); + return $result; + } + } diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index a339b142..a69cf852 100644 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -77,12 +77,14 @@ class ClientPolicyModel extends Model ->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') ->select('policy_type.policy_type as policy_type_name') + ->select('client_branch.branch_name as branch_name') ->join('insurers', 'insurers.id = client_policy.insurer_id') ->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id') ->join('tpa', 'tpa.id = client_policy.tpa_id', 'left') ->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left') ->join('policies', 'policies.id = client_policy.policy_id') ->join('policy_type', 'policy_type.id = policies.policy_type_id') + ->join('client_branch', 'client_branch.id = client_policy.client_branch_id') ->where('client_policy.client_id', $client_id) ->where('client_policy.policy_status', 1) ->where('client_policy.is_active', 1) diff --git a/app/Views/cd_master_list.php b/app/Views/cd_master_list.php index 7a001b39..21e599ce 100644 --- a/app/Views/cd_master_list.php +++ b/app/Views/cd_master_list.php @@ -58,12 +58,12 @@ table.dataTable thead th { @@ -290,4 +290,50 @@ table.dataTable thead th { }) + +function removeCDMaster(element) { + + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this CD.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { + + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('CD removed successfully.', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove CD.', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.log('Something Wrong!', 'warning'); + } + }); + } + + }); + +} + \ No newline at end of file diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 213f47c2..81b308e4 100644 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -1,11 +1,12 @@
- +
- +
-
- +
+ @@ -23,52 +24,51 @@
- +
- +
-
- - - + + + +
- +
- - + +
- +
- - + +
- - + +
@@ -79,26 +79,37 @@
- +
- +
- +
- +
- - + +
@@ -119,168 +130,196 @@ \ No newline at end of file diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 4548631a..2d84afdf 100644 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -59,7 +59,9 @@ table.dataTable thead th {
@@ -111,38 +113,47 @@ table.dataTable thead th { function removeClient(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - location.reload(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this client.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - } else { - toastr.warning('Remove Not Done!', 'warning'); - } + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('Client removed successfully.', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove client.', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.log('Something Wrong!', 'warning'); + } + }); } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); - } - }); - + + }); } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index e5626a3a..a27e1d92 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -7,14 +7,15 @@
-
+
+ - + @@ -263,8 +264,9 @@ + - + + - +
Insurer PolicyClient Branch TPA DateEnrollment
Status
Enrollment Status Status Action
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name} ${tpaValue}${(item.policy_start_date)} /
${(item.policy_end_date)}
${(item.policy_start_date)} / ${(item.policy_end_date)} ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} @@ -481,8 +483,9 @@
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name} ${tpaValue}${rearrangeDateFormat(item.policy_start_date)} /
${rearrangeDateFormat(item.policy_end_date)}
${rearrangeDateFormat(item.policy_start_date)} / ${rearrangeDateFormat(item.policy_end_date)} ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} diff --git a/app/Views/client_rm.php b/app/Views/client_rm.php index a47280ee..73ad031c 100644 --- a/app/Views/client_rm.php +++ b/app/Views/client_rm.php @@ -16,7 +16,7 @@
- +
- +