From cfddad848577e47ef5a1a9286825aec31bc7deff Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 24 Feb 2026 14:52:28 +0530 Subject: [PATCH] FEAT_HR_TPA_DASHBOARD --- app/Config/Acl.php | 1 + app/Config/Routes.php | 2 + app/Controllers/EmployeeRestController.php | 43 ++++++++++++++++ app/Controllers/TestingController.php | 58 ++++++++++++++++++++++ app/Models/TPAModel.php | 1 + 5 files changed, 105 insertions(+) diff --git a/app/Config/Acl.php b/app/Config/Acl.php index af8b94f3..86760bb0 100644 --- a/app/Config/Acl.php +++ b/app/Config/Acl.php @@ -29,6 +29,7 @@ class Acl '#^/util/view_log#' => ['roles' => [ADMIN_ROLE_ID]], '#^/util/download_log#' => ['roles' => [ADMIN_ROLE_ID]], '#^/metaDashboardDemo#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]], + '#^/metaTpaDashboardDemo#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]], // ===================== PUBLIC DOWNLOADS / FORMS ===================== '#^/download-#' => ['public' => true], diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0600dbb8..387c3dfd 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -32,6 +32,7 @@ $routes->get('/fedeploy', 'DeployController::fedeploy_view', ['filter' => 'authM $routes->post('/fedeploy', 'DeployController::fedeploy', ['filter' => 'authMVC']); $routes->get('/visitOffBoardCheck', 'EmployeeController::visitOffBoardCheck'); $routes->get('/metaDashboardDemo', 'TestingController::metaDashboardDemo'); +$routes->get('/metaTpaDashboardDemo', 'TestingController::metaTpaDashboardDemo'); // Reminder Mail Notification @@ -670,6 +671,7 @@ $routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratel $routes->post("hrFileUpload", "EmployeeRestController::hrFileUpload"); $routes->post("updateHrFileUploadData", "EmployeeRestController::updateHrFileUploadData"); $routes->post("getHrDashboad", "EmployeeRestController::getHrDashboad"); + $routes->post("getHrTpaDashboard", "EmployeeRestController::getHrTpaDashboard"); //thz_master's diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 6d91d543..50398782 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -5533,6 +5533,49 @@ class EmployeeRestController extends AdminController 'metabaseUrl' => 'https://nsights.nhanceindia.in', ]); } + + public function getHrTpaDashboard() + { + $METABASE_SECRET_KEY = getenv('METABASE_SECRET_KEY'); + $received_data = $this->request->getJSON(true) ?? null; + + $policy_id = $received_data['client_policy_id'] ?? 4687; + + $client_policy_data = $this->clientPolicyModel + ->select('tpa.dashboard_id') + ->join('tpa', 'client_policy.tpa_id = tpa.id') + ->where('client_policy.id', $policy_id) + ->first(); + + $database_id = isset($client_policy_data['dashboard_id']) ? (int) $client_policy_data['dashboard_id'] : null; + + if (empty($database_id)) { + return $this->respond([ + 'status' => 'failed', + 'message' => 'There is no dashboard for this TPA.', + 'data' => [] + ]); + } + + $payload = [ + 'resource' => [ + 'dashboard' => $database_id + ], + 'exp' => time() + (10 * 60), // 10 minutes + 'params' => (object)[] + ]; + + $token = JWT::encode($payload, $METABASE_SECRET_KEY, 'HS256'); + + return $this->respond([ + 'status' => 'success', + 'message' => 'Form data received successfully!', + 'data' => [ + 'metabaseToken' => $token, + 'metabaseUrl' => 'https://nsights.nhanceindia.in' + ] + ]); + } // get policy files diff --git a/app/Controllers/TestingController.php b/app/Controllers/TestingController.php index 66957ea8..aaf62878 100644 --- a/app/Controllers/TestingController.php +++ b/app/Controllers/TestingController.php @@ -4,6 +4,7 @@ namespace App\Controllers; use App\Controllers\BaseController; use App\Models\EmployeePolicyModel; +use App\Models\ClientPolicyModel; use App\Models\InsurerBranchModel; use App\Models\RFQModel; use CodeIgniter\HTTP\ResponseInterface; @@ -23,10 +24,12 @@ class TestingController extends BaseController { use ResponseTrait; protected $myLogger; + protected $ClientPolicyModel; public function __construct() { $this->myLogger = \Config\Services::mylogger(); + $this->ClientPolicyModel = new ClientPolicyModel(); } public function saveForm() @@ -1060,4 +1063,59 @@ class TestingController extends BaseController return $this->respond(['status' => 'failed', 'code' => '500' , 'message' => 'Error: ' . $e->getMessage()], 200); } } + + public function metaTpaDashboardDemo() + { + $METABASE_SECRET_KEY = getenv('METABASE_SECRET_KEY'); + $policy_id = $this->request->getGet('client_policy') ?? 4687; + + $client_policy_data = $this->ClientPolicyModel + ->select('tpa.dashboard_id') + ->join('tpa', 'client_policy.tpa_id = tpa.id') + ->where('client_policy.id', $policy_id) + ->first(); + + $database_id = isset($client_policy_data['dashboard_id']) ? (int) $client_policy_data['dashboard_id'] : null; + + if (empty($database_id)) { + + if ($this->request->getGet('api') == 1) { + return $this->respond([ + 'status' => 'failed', + 'message' => 'There is no dashboard for this TPA.', + 'data' => [] + ]); + } + + return view('errors/404', [ + 'message' => 'There is no dashboard for this TPA.' + ]); + } + + $payload = [ + 'resource' => [ + 'dashboard' => $database_id + ], + 'exp' => time() + (10 * 60), // 10 minutes + 'params' => (object)[] + ]; + + $token = JWT::encode($payload, $METABASE_SECRET_KEY, 'HS256'); + + if ($this->request->getGet('api') == 1) { + return $this->respond([ + 'status' => 'success', + 'message' => 'Form data received successfully!', + 'data' => [ + 'metabaseToken' => $token, + 'metabaseUrl' => 'https://nsights.nhanceindia.in' + ] + ]); + } + + return view('meta_dashboard_demo_one', [ + 'metabaseToken' => $token, + 'metabaseUrl' => 'https://nsights.nhanceindia.in', + ]); + } } diff --git a/app/Models/TPAModel.php b/app/Models/TPAModel.php index fe3f30cd..679cae2a 100755 --- a/app/Models/TPAModel.php +++ b/app/Models/TPAModel.php @@ -19,5 +19,6 @@ class TPAModel extends Model "created_by", "updated_by", "is_active", + "dashboard_id", ]; }