From f573b33221369486e032a22acf3dc96b84a04713 Mon Sep 17 00:00:00 2001 From: velz Date: Thu, 29 Jan 2026 09:25:42 +0530 Subject: [PATCH] FEAT_VISIT_DELETE&FIX_HEADER&FOOTER --- app/Config/Acl.php | 1 + app/Config/Routes.php | 1 + app/Controllers/EmployeeController.php | 86 +++++++++++++ app/Views/layout/footer.php | 116 ++++++++++-------- ...footer_old_outdated.php => footer_new.php} | 116 ++++++++---------- app/Views/layout/header.php | 19 ++- ...header_old_outdated.php => header_new.php} | 19 +-- 7 files changed, 223 insertions(+), 135 deletions(-) rename app/Views/layout/{footer_old_outdated.php => footer_new.php} (92%) rename app/Views/layout/{header_old_outdated.php => header_new.php} (99%) diff --git a/app/Config/Acl.php b/app/Config/Acl.php index f2f4ecca..b89e53a9 100644 --- a/app/Config/Acl.php +++ b/app/Config/Acl.php @@ -16,6 +16,7 @@ class Acl '#^/getVerifiedPosUserData#' => ['public' => true], '#^/swagger#' => ['roles' => [ADMIN_ROLE_ID]], '#^/fedeploy#' => ['roles' => [ADMIN_ROLE_ID]], + '#^/visitOffBoardCheck#' => ['roles' => [ADMIN_ROLE_ID]], // ===================== PUBLIC DOWNLOADS / FORMS ===================== '#^/download-#' => ['public' => true], diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4bf4b954..b31bbbfa 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -21,6 +21,7 @@ $routes->get('/chatbot', 'ChatbotControllerNew::chatbot'); $routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']); $routes->get('/fedeploy', 'DeployController::fedeploy_view', ['filter' => 'authMVC']); $routes->post('/fedeploy', 'DeployController::fedeploy', ['filter' => 'authMVC']); +$routes->get('/visitOffBoardCheck', 'EmployeeController::visitOffBoardCheck'); // Reminder Mail Notification diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 41eef6df..f48822a7 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -4421,6 +4421,92 @@ class EmployeeController extends AdminController $this->myLogger->logme('error', "$log_search_context". "END Batch {$batch_no}"); } + public function visitOffBoardCheck() + { + $params = [ + "memberIds" => ["adi_1034292323", "EMPENHANCE-M1", "EMPENHANCE-M3"], + // "policyNumber" => "570000/48/2026/290", + "policyNumber" => "09823428509239", + "source" => "NHANCE" + ]; + print_rr($this->visitOffBoard($params)); + } + + /** + * Executes the Delete Policy API call. + * + * @param array $params Contains 'memberIds', 'policyNumber', and 'source'. + * @return array + */ + public function visitOffBoard(array $params) + { + // 1. Load credentials from .env + $apiUrl = env('WELLNESS_ONBOARD_ENDPOINT_URL'); + $apiToken = env('WELLNESS_ONBOARD_AUTHORIZATION'); + + // 2. Initialize the CI4 CURL service + $client = \Config\Services::curlrequest([ + 'base_uri' => $apiUrl, + 'timeout' => 30, + ]); + + // $client = Services::curlrequest([ + // 'base_uri' => $apiUrl, + // 'timeout' => 30, + // ]); + $params['source'] = 'NHANCE'; + try { + // Log the start of the request for traceability + $this->myLogger->logme('error', 'VISIT_OFFBOARD: ' . ($params['policyNumber'] ?? 'N/A')); + + // 3. Perform the POST request + $response = $client->request('POST', '', [ + 'headers' => [ + 'Authorization' => 'JWT ' . $apiToken, + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ], + 'json' => [ + 'memberIds' => $params['memberIds'] ?? [], + 'policyNumber' => $params['policyNumber'] ?? '', + 'source' => $params['source'] ?? '', + ], + 'http_errors' => false, // Prevents throwing exceptions on 4xx/5xx responses + ]); + + $statusCode = $response->getStatusCode(); + $rawBody = $response->getBody(); + $result = json_decode($rawBody, true); + + // 4. Handle based on HTTP Status Code + if ($statusCode >= 200 && $statusCode < 300) { + $this->myLogger->logme('error', "VISIT_OFFBOARD API Success (Code $statusCode): Policy deleted."); + return [ + 'status' => true, + 'data' => $result + ]; + } + + // Log API-level errors (4xx or 5xx) + $this->myLogger->logme('error', "VISIT_OFFBOARD API Failure (Code $statusCode): " . json_encode($rawBody)); + return [ + 'status' => false, + 'message' => 'The API returned an error response.', + 'code' => $statusCode, + 'details' => $result + ]; + + } catch (Exception $e) { + // 5. Catch network or system exceptions + $this->myLogger->logme('error', 'VISIT_OFFBOARD API Exception: ' . $e->getMessage()); + return [ + 'status' => false, + 'message' => 'A critical error occurred while contacting the API.', + 'error' => $e->getMessage() + ]; + } + } + } diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index 1642a758..0fffbdc6 100755 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -66,69 +66,87 @@ - +
- - - - + + - - - - + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + - + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + - - - - + + + - - - + + + + - - - - - - - - + + + + + + - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + - - - + + + + - - - - + + + + + + + - - + + + + + + - - + + - - - - - + + + + @@ -84,7 +83,7 @@ - + diff --git a/app/Views/layout/header_old_outdated.php b/app/Views/layout/header_new.php similarity index 99% rename from app/Views/layout/header_old_outdated.php rename to app/Views/layout/header_new.php index 73c56916..b5bfd6fa 100644 --- a/app/Views/layout/header_old_outdated.php +++ b/app/Views/layout/header_new.php @@ -50,17 +50,18 @@ /assets/css/jodit.css" rel="stylesheet" type="text/css" /> - - + + - - + + - - + + + + + - - @@ -83,7 +84,7 @@ - +