From ad355a0dd36e8cd73dc7cf069e9d5443505948f8 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 31 Jul 2025 17:34:37 +0530 Subject: [PATCH 1/2] FIX_LIVE_ISSUE_GET_CLIENT_DETAILS_API ISSUE : RV --- app/Controllers/RestAuthenticationController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 976a35f..04902bc 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -425,6 +425,7 @@ class RestAuthenticationController extends AdminController // print_r($employeeData); die; unset($employeeData['employee_id']); + $employeeData['token_type'] = "pre"; $result = JWTToken::encode($employeeData); if(isset($this->request->getJSON()->otp)){ @@ -959,6 +960,7 @@ class RestAuthenticationController extends AdminController } unset($employeeData['employee_id']); + $employeeData['token_type'] = "pre"; $result = JWTToken::encode($employeeData); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyMpin: Calling third-party API - verifyMpin to get the POST employee data"); From 7e2a4c5aeb1d2b00c6219de2f3b7b0402fab5b9e Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 2 Aug 2025 14:35:59 +0530 Subject: [PATCH 2/2] CHANGE_CLIENT_DELETE_DEMO_CLIENT_WIPE : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 242 ++++++++++ app/Views/client_list.php | 692 +++++++++++++++------------ 3 files changed, 618 insertions(+), 317 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index b6cfa39..0f128f9 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -70,6 +70,7 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) { $routes->get('deposit/(:num)', 'ClientController::deposit/$1'); $routes->get('remove/(:num)', 'ClientController::removeClient/$1'); $routes->get("list/(:any)", "ClientController::editClientOnboarding/$1"); + $routes->post('wipe', 'ClientController::wipeDemoClient'); // application/config/routes.php // Add a route for the view_Deposit method diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index e1523c0..678100a 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4880,4 +4880,246 @@ class ClientController extends AdminController return $this->respond(['status'=> false,'code'=>404,'message'=>'Mapping Deletion Failed'],200); } } + + // -------------------- DEMO CLIENT FUNCTION -------------------------------------------------------------------------------------------- + + public function wipeDemoClient() + { + $this->myLogger->logme('error', "========================================"); + $this->myLogger->logme('error', "WIPE DEMO CLIENT FUNCTION STARTED"); + $this->myLogger->logme('error', "========================================"); + + $this->myLogger->logme('error', "Request Payload: " . json_encode($this->request->getPost() ?? [])); + $client_id = $this->request->getPost('client_id'); + + if (empty($client_id)) { + $this->myLogger->logme('error', "ERROR: Client ID is required"); + return $this->respond(['status' => false, 'message' => 'Client id required'], 404); + } + + $this->myLogger->logme('error', "Client ID to wipe: " . $client_id); + $this->myLogger->logme('error', "----------------------------------------"); + + // ======================================== + // 1. CLIENT MODEL DELETION + // ======================================== + $this->myLogger->logme('error', "1. PROCESSING CLIENT MODEL"); + $client_data = $this->clientModel->where('id', $client_id)->where('is_active', 1)->first(); + $this->myLogger->logme('error', " Found Client Data: " . json_encode($client_data ?? [])); + + if (!empty($client_data)) { + $is_deleted = $this->clientModel->where('id', $client_id)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Client data removed successfully"); + } else { + $this->myLogger->logme('error', " ✗ Failed to delete client record"); + } + } else { + $this->myLogger->logme('error', " ✗ Client not found or inactive"); + return $this->respond(['status' => false, 'message' => 'Client not found'], 404); + } + $this->myLogger->logme('error', "----------------------------------------"); + + // ======================================== + // 2. CLIENT RM MODEL DELETION + // ======================================== + $this->myLogger->logme('error', "2. PROCESSING CLIENT RM MODEL"); + $client_rm_data = $this->clientRMModel->where('client_id', $client_id)->first(); + $this->myLogger->logme('error', " Found Client RM Data: " . json_encode($client_rm_data ?? [])); + + if (!empty($client_rm_data)) { + $is_deleted = $this->clientRMModel->where('client_id', $client_id)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Client RM data removed successfully"); + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Client RM record"); + } + } else { + $this->myLogger->logme('error', " ℹ No Client RM data found"); + } + $this->myLogger->logme('error', "----------------------------------------"); + + // ======================================== + // 3. CLIENT KYC DOCS MODEL DELETION + // ======================================== + $this->myLogger->logme('error', "3. PROCESSING CLIENT KYC DOCS MODEL"); + $client_kyc_data = $this->clientKYCDocsModel->where('client_id', $client_id)->findAll(); + $this->myLogger->logme('error', " Found Client KYC Records: " . count($client_kyc_data ?? [])); + $this->myLogger->logme('error', " Client KYC Data: " . json_encode($client_kyc_data ?? [])); + + if (!empty($client_kyc_data)) { + $is_deleted = $this->clientKYCDocsModel->where('client_id', $client_id)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Client KYC Docs data removed successfully"); + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Client KYC Docs records"); + } + } else { + $this->myLogger->logme('error', " ℹ No Client KYC Docs data found"); + } + $this->myLogger->logme('error', "----------------------------------------"); + + // ======================================== + // 4. CLIENT BRANCH MODEL DELETION + // ======================================== + $this->myLogger->logme('error', "4. PROCESSING CLIENT BRANCH MODEL"); + $client_branch_data = $this->clientBranchModel->where('client_id', $client_id)->findAll(); + $branch_ids = array_column($client_branch_data, 'id') ?? []; + $this->myLogger->logme('error', " Found Client Branch Records: " . count($client_branch_data ?? [])); + $this->myLogger->logme('error', " Branch IDs: " . json_encode($branch_ids)); + $this->myLogger->logme('error', " Client Branch Data: " . json_encode($client_branch_data ?? [])); + + if (!empty($client_branch_data)) { + $is_deleted = $this->clientBranchModel->where('client_id', $client_id)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Client Branch data removed successfully"); + + // Delete related Level Contact data + if (!empty($branch_ids)) { + $this->myLogger->logme('error', " 4a. PROCESSING RELATED LEVEL CONTACT DATA"); + $level_contact_data = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->findAll(); + $this->myLogger->logme('error', " Found Level Contact Records: " . count($level_contact_data ?? [])); + $this->myLogger->logme('error', " Level Contact Data: " . json_encode($level_contact_data ?? [])); + + $is_deleted = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Level Contact data removed successfully"); + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Level Contact records"); + } + } else { + $this->myLogger->logme('error', " ℹ No Branch IDs available for Level Contact deletion"); + } + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Client Branch records"); + } + } else { + $this->myLogger->logme('error', " ℹ No Client Branch data found"); + } + $this->myLogger->logme('error', "----------------------------------------"); + + // ======================================== + // 5. CLIENT POLICY MODEL DELETION + // ======================================== + $this->myLogger->logme('error', "5. PROCESSING CLIENT POLICY MODEL"); + $client_policy_data = $this->clientPolicyModel->where('client_id', $client_id)->findAll(); + $policy_ids = array_column($client_policy_data, 'id') ?? []; + $this->myLogger->logme('error', " Found Client Policy Records: " . count($client_policy_data ?? [])); + $this->myLogger->logme('error', " Policy IDs: " . json_encode($policy_ids)); + $this->myLogger->logme('error', " Client Policy Data: " . json_encode($client_policy_data ?? [])); + + if (!empty($client_policy_data)) { + $is_deleted = $this->clientPolicyModel->where('client_id', $client_id)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Client Policy data removed successfully"); + + // Delete related Employee Policy data + if (!empty($policy_ids)) { + $this->myLogger->logme('error', " 5a. PROCESSING RELATED EMPLOYEE POLICY DATA"); + $employee_policy_data = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->findAll(); + $this->myLogger->logme('error', " Found Employee Policy Records: " . count($employee_policy_data ?? [])); + + $is_deleted = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Employee Policy data removed successfully"); + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Employee Policy records"); + } + } else { + $this->myLogger->logme('error', " ℹ No Policy IDs available for Employee Policy deletion"); + } + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Client Policy records"); + } + } else { + $this->myLogger->logme('error', " ℹ No Client Policy data found"); + } + $this->myLogger->logme('error', "----------------------------------------"); + + // ======================================== + // 6. EMPLOYEE MODEL DELETION + // ======================================== + $this->myLogger->logme('error', "6. PROCESSING EMPLOYEE MODEL"); + $employee_data = $this->employeeModel->where('client_id', $client_id)->findAll(); + $this->myLogger->logme('error', " Found Employee Records: " . count($employee_data ?? [])); + + if (!empty($employee_data)) { + $is_deleted = $this->employeeModel->where('client_id', $client_id)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Employee data removed successfully"); + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Employee records"); + } + } else { + $this->myLogger->logme('error', " ℹ No Employee data found"); + } + $this->myLogger->logme('error', "----------------------------------------"); + + + // ======================================== + // 7. POLICY PREMIUM 1 MODEL DELETION + // ======================================== + $this->myLogger->logme('error', "8. PROCESSING POLICY PREMIUM 1 MODEL"); + $policy_premium1_data = $this->policyPremium1Model->where('client_id', $client_id)->findAll(); + $this->myLogger->logme('error', " Found Policy Premium 1 Records: " . count($policy_premium1_data ?? [])); + + if (!empty($policy_premium1_data)) { + $is_deleted = $this->policyPremium1Model->where('client_id', $client_id)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Policy Premium 1 data removed successfully"); + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Policy Premium 1 records"); + } + } else { + $this->myLogger->logme('error', " ℹ No Policy Premium 1 data found"); + } + $this->myLogger->logme('error', "----------------------------------------"); + + // ======================================== + // 8. POLICY PREMIUM 2 MODEL DELETION + // ======================================== + $this->myLogger->logme('error', "9. PROCESSING POLICY PREMIUM 2 MODEL"); + $policy_premium2_data = $this->policyPremium2Model->where('client_id', $client_id)->findAll(); + $this->myLogger->logme('error', " Found Policy Premium 2 Records: " . count($policy_premium2_data ?? [])); + + if (!empty($policy_premium2_data)) { + $is_deleted = $this->policyPremium2Model->where('client_id', $client_id)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Policy Premium 2 data removed successfully"); + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Policy Premium 2 records"); + } + } else { + $this->myLogger->logme('error', " ℹ No Policy Premium 2 data found"); + } + $this->myLogger->logme('error', "----------------------------------------"); + + // ======================================== + // 9. NOTIFICATION MODEL DELETION + // ======================================== + $this->myLogger->logme('error', "10. PROCESSING NOTIFICATION MODEL"); + $notification_data = $this->notificationModel->where('client_id', $client_id)->findAll(); + $this->myLogger->logme('error', " Found Notification Records: " . count($notification_data ?? [])); + $this->myLogger->logme('error', " Notification Data: " . json_encode($notification_data ?? [])); + + if (!empty($notification_data)) { + $is_deleted = $this->notificationModel->where('client_id', $client_id)->delete(); + if ($is_deleted) { + $this->myLogger->logme('error', " ✓ Notification data removed successfully"); + } else { + $this->myLogger->logme('error', " ✗ Failed to delete Notification records"); + } + } else { + $this->myLogger->logme('error', " ℹ No Notification data found"); + } + $this->myLogger->logme('error', "----------------------------------------"); + + + $this->myLogger->logme('error', "========================================"); + $this->myLogger->logme('error', "WIPE DEMO CLIENT FUNCTION COMPLETED"); + $this->myLogger->logme('error', "Client ID: " . $client_id . " - Successfully processed"); + $this->myLogger->logme('error', "========================================"); + + return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200); + } } diff --git a/app/Views/client_list.php b/app/Views/client_list.php index f7f8296..6ecfc2c 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -1,48 +1,48 @@
@@ -71,33 +71,31 @@ table.dataTable thead th { - - - client_name; ?> ( short_name; ?> ) - - - - client_id == $row->id): ?> - account_manager . ', '; ?> - - - - - - -
@@ -142,111 +139,302 @@ table.dataTable thead th {
+ + + function featchClient(){ - \ No newline at end of file