Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
d8251dea15
@ -842,3 +842,13 @@ $routes->group('bds_upload', function($routes) {
|
|||||||
$routes->get('getBdsDumpFileErrorData',"PolicyTransactionController::getBdsDumpFileErrorData");
|
$routes->get('getBdsDumpFileErrorData',"PolicyTransactionController::getBdsDumpFileErrorData");
|
||||||
$routes->get('getBdsDumpExcelFileErrors/(:any)',"PolicyTransactionController::getBdsDumpExcelFileErrors/$1");
|
$routes->get('getBdsDumpExcelFileErrors/(:any)',"PolicyTransactionController::getBdsDumpExcelFileErrors/$1");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------------------------------
|
||||||
|
$routes->group('logs', function($routes) {
|
||||||
|
$routes->get('/', 'LogController::index');
|
||||||
|
$routes->get('view/(:segment)', 'LogController::view/$1');
|
||||||
|
$routes->get('download/(:segment)', 'LogController::download/$1');
|
||||||
|
$routes->get('delete/(:segment)', 'LogController::delete/$1');
|
||||||
|
$routes->get('clearAll', 'LogController::clearAll');
|
||||||
|
});
|
||||||
|
|||||||
@ -45,9 +45,14 @@ class ApiServiceController extends BaseController
|
|||||||
|
|
||||||
$tpaID = $data['tpa_id'];
|
$tpaID = $data['tpa_id'];
|
||||||
|
|
||||||
if ($tpaID == $this->medi_assist_primary_key) { // MediAssist
|
if ($tpaID == $this->medi_assist_primary_key)
|
||||||
|
{ // MediAssist
|
||||||
$mediAssistController = new MediAssistApiController();
|
$mediAssistController = new MediAssistApiController();
|
||||||
return $mediAssistController->SubmitClaim($claimId);
|
return $mediAssistController->SubmitClaim($claimId);
|
||||||
|
}else if ($tpaID == $this->vidal_primary_key)
|
||||||
|
{ // Vidal
|
||||||
|
$vidalApiController = new VidalApiController;
|
||||||
|
return $vidalApiController->SubmitClaim($claimId);
|
||||||
}else{
|
}else{
|
||||||
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
|
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
|
||||||
}
|
}
|
||||||
@ -271,76 +276,65 @@ class ApiServiceController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//wellness sso url generator landing
|
||||||
|
public function getWellnessUrl($emp_id)
|
||||||
public function getWellnessUrl()
|
|
||||||
{
|
{
|
||||||
|
// $emp_id = $this->request->getGet('emp_id');
|
||||||
$emp_id = $this->request->getGet('emp_id');
|
|
||||||
$client_policy_id = $this->request->getGet('client_policy_id');
|
|
||||||
|
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
|
$data = $db->table('employees e')
|
||||||
// $data = $db->table('employees e')
|
|
||||||
// ->select('pt.policy_type,
|
|
||||||
// e.name, e.email_corporate as email, e.mobile as phone, e.emp_code as memberId, e.gender, e.dob, e.relationship as relation,
|
|
||||||
// cp.policy_no as policyNumber, cp.policy_no as employeeId, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate')
|
|
||||||
// ->join('employee_polices ep', 'e.id = ep.employee_id')
|
|
||||||
// ->join('client_policy cp', 'ep.client_policy_id = cp.id')
|
|
||||||
// ->join('policy_type pt', 'cp.policy_type_id = pt.id')
|
|
||||||
// ->where('e.id', $emp_id)
|
|
||||||
// ->where('e.emp_status', 'active')
|
|
||||||
// ->where('ep.status', 'active')
|
|
||||||
// ->where('e.is_active', 1)
|
|
||||||
// ->where('ep.is_active', 1)
|
|
||||||
// ->get()
|
|
||||||
// ->getResultArray();
|
|
||||||
|
|
||||||
$data = $db->table('employee_polices ep')
|
|
||||||
->select('pt.policy_type,
|
->select('pt.policy_type,
|
||||||
e.name, e.email_corporate as email, e.mobile as phone, e.emp_code as memberId, e.gender, e.dob, e.relationship as relation, e.id as employeeId
|
e.name, e.email_corporate as email, e.mobile as phone, e.emp_code as memberId, e.gender, e.dob, e.relationship as relation,
|
||||||
cp.policy_no as policyNumber, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate, cp.wellness_plan_id as planId')
|
cp.policy_no as policyNumber, ep.employee_id as employeeId, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate , cp.wellness_plan_id as planId , cp.wellness_vendor_id')
|
||||||
->join('employees e', 'e.id = ep.employee_id')
|
->join('employee_polices ep', 'e.id = ep.employee_id')
|
||||||
->join('client_policy cp', 'ep.client_policy_id = cp.id')
|
->join('client_policy cp', 'ep.client_policy_id = cp.id')
|
||||||
->join('policy_type pt', 'cp.policy_type_id = pt.id')
|
->join('policy_type pt', 'cp.policy_type_id = pt.id')
|
||||||
->where('ep.employee_id', $emp_id)
|
->where('e.id', $emp_id)
|
||||||
->where('ep.client_policy_id', $client_policy_id)
|
->where('e.emp_status', 'active')
|
||||||
->where('ep.status', 'active')
|
->where('ep.status', 'active')
|
||||||
|
->where('e.is_active', 1)
|
||||||
->where('ep.is_active', 1)
|
->where('ep.is_active', 1)
|
||||||
->get()
|
->get()
|
||||||
->getRow();
|
->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$userParams = [];
|
$userParams = [];
|
||||||
if(!empty($data))
|
foreach ($data as $row) {
|
||||||
{
|
|
||||||
$userParams['name'] = $data->name;
|
|
||||||
$userParams['email'] = $data->email;
|
|
||||||
$userParams['phone'] = $data->phone;
|
|
||||||
$userParams['memberId'] = $data->employeeId; // memberId is unique primary key.
|
|
||||||
$userParams['gender'] = $data->gender;
|
|
||||||
$userParams['dob'] = $data->dob;
|
|
||||||
$userParams['relation'] = $data->relation;
|
|
||||||
$userParams['policyNumber'] = $data->policyNumber;
|
|
||||||
$userParams['employeeId'] = $data->memberId;
|
|
||||||
$userParams['policyStartDate']= $data->policyStartDate;
|
|
||||||
$userParams['policyEndDate'] = $data->policyEndDate;
|
|
||||||
$userParams['policyName'] = 'Nhance ' . $data->policy_type;
|
|
||||||
$userParams['planId'] = $data->planId;
|
|
||||||
$userParams['moduleName'] = 'home';
|
|
||||||
|
|
||||||
|
if($row['wellness_vendor_id'] != null)
|
||||||
|
{
|
||||||
|
$vidalApiController = new VidalApiController();
|
||||||
|
return $vidalApiController->getWellnessSSORedirectUrl($row['email']);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ($row['planId'] != null) // VISIT
|
||||||
|
{
|
||||||
|
$userParams['name'] = $row['name'];
|
||||||
|
$userParams['email'] = $row['email'];
|
||||||
|
$userParams['phone'] = $row['phone'];
|
||||||
|
$userParams['memberId'] = $row['employeeId']; // memberId is unique primary key.
|
||||||
|
$userParams['gender'] = $row['gender'];
|
||||||
|
$userParams['dob'] = $row['dob'];
|
||||||
|
$userParams['relation'] = $row['relation'];
|
||||||
|
$userParams['policyNumber'] = $row['policyNumber'];
|
||||||
|
$userParams['employeeId'] = $row['memberId'];
|
||||||
|
$userParams['policyStartDate']= $row['policyStartDate'];
|
||||||
|
$userParams['policyEndDate'] = $row['policyEndDate'];
|
||||||
|
$userParams['policyName'] = $row['policy_type'];
|
||||||
|
$userParams['planId'] = $row['planId'];
|
||||||
|
$userParams['moduleName'] = 'home';
|
||||||
|
break; // stop after first GMC match
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dd($userParams);
|
|
||||||
|
|
||||||
if (empty($userParams)) {
|
if (empty($userParams)) {
|
||||||
return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200);
|
return ['status' => 'failed','message' => 'Coming soon........!'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// echo 'coming';die();
|
||||||
// Derive 32-byte key from SHA256
|
// Derive 32-byte key from SHA256
|
||||||
$derivedKey = hash('sha256', env('VISIT_SECRET_KEY'), true);
|
$derivedKey = hash('sha256', env('VISIT_SECRET_KEY'), true);
|
||||||
|
|
||||||
// Build query string like Node.js
|
// Build query string like Node.js
|
||||||
$plainText = '';
|
$plainText = '';
|
||||||
foreach ($userParams as $k => $v) {
|
foreach ($userParams as $k => $v) {
|
||||||
@ -354,153 +348,114 @@ class ApiServiceController extends BaseController
|
|||||||
|
|
||||||
// Base64URL encode (same as Node.js output)
|
// Base64URL encode (same as Node.js output)
|
||||||
$output = rtrim(strtr(base64_encode($encrypted), '+/', '-_'), '=');
|
$output = rtrim(strtr(base64_encode($encrypted), '+/', '-_'), '=');
|
||||||
|
|
||||||
$baseURL = env('VISIT_BASE_URL');
|
$baseURL = env('VISIT_BASE_URL');
|
||||||
$clientId = env('VISIT_CLIENT_ID');
|
$clientId = env('VISIT_CLIENT_ID');
|
||||||
$finalUrl = $baseURL . '/sso?userParams=' . $output . '&clientId=' . $clientId;
|
$finalUrl = $baseURL . '/sso?userParams=' . $output . '&clientId=' . $clientId;
|
||||||
|
|
||||||
if (!empty($finalUrl)) {
|
if (!empty($finalUrl)) {
|
||||||
log_message('error', 'VISIT SSO | emp_id: '.$emp_id.' | URL: '.$finalUrl);
|
log_message('error', 'VISIT SSO | emp_id: '.$emp_id.' | URL: '.$finalUrl);
|
||||||
return $this->respond(['status' => 'success','data' => $finalUrl], 200);
|
return ['status' => 'success','data' => $finalUrl];
|
||||||
} else {
|
} else {
|
||||||
return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200);
|
return ['status' => 'failed','message' => 'Coming soon........!'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSSORedirectUrl($email = 'test@getvisitapp.com')
|
|
||||||
{
|
|
||||||
log_message('info', "SSO: Starting authentication for email: $email");
|
|
||||||
|
|
||||||
// ---------- CONFIG ----------
|
|
||||||
$authUrl = env('VIDAL_WELLNESS_BASE_URL');
|
|
||||||
$subscriptionKey = env('VIDAL_WELLNESS_SUBSCRIPTION_KEY');
|
|
||||||
$apiVersion = "1";
|
|
||||||
|
|
||||||
// Provided Base64 AES key
|
|
||||||
$base64Key = env('VIDAL_WELLNESS_BASE64_KEY');
|
|
||||||
$key = base64_decode($base64Key);
|
|
||||||
|
|
||||||
log_message('info', "SSO: Config loaded, Auth URL: $authUrl");
|
|
||||||
|
|
||||||
// ---------- STEP 1: Build plaintext payload ----------
|
// public function getWellnessUrl()
|
||||||
$plainPayload = json_encode([
|
// {
|
||||||
"email" => $email,
|
|
||||||
// "corporateId" => env('VIDAL_WELLNESS_CORPORATE_ID'),
|
|
||||||
"urlIdentifier" => env('VIDAL_WELLNESS_URL_IDENTIFIER')
|
|
||||||
]);
|
|
||||||
|
|
||||||
// ---------- STEP 2: Encrypt payload ----------
|
// $emp_id = $this->request->getGet('emp_id');
|
||||||
$iv = random_bytes(16);
|
// $client_policy_id = $this->request->getGet('client_policy_id');
|
||||||
$encryptedRaw = openssl_encrypt($plainPayload, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $iv);
|
|
||||||
|
|
||||||
$encryptedPayload = base64_encode($iv) . ":" . base64_encode($encryptedRaw);
|
// $db = \Config\Database::connect();
|
||||||
|
|
||||||
log_message('info', "SSO: Payload encrypted successfully");
|
|
||||||
|
|
||||||
// ---------- STEP 3: Call Authentication API ----------
|
// // $data = $db->table('employees e')
|
||||||
$requestBody = json_encode([
|
// // ->select('pt.policy_type,
|
||||||
"payload" => $encryptedPayload,
|
// // e.name, e.email_corporate as email, e.mobile as phone, e.emp_code as memberId, e.gender, e.dob, e.relationship as relation,
|
||||||
"source" => env('VIDAL_WELLNESS_SUB_PARTNER_ID'),
|
// // cp.policy_no as policyNumber, cp.policy_no as employeeId, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate')
|
||||||
"subPartnerId" => env('VIDAL_WELLNESS_SUB_PARTNER_ID')
|
// // ->join('employee_polices ep', 'e.id = ep.employee_id')
|
||||||
]);
|
// // ->join('client_policy cp', 'ep.client_policy_id = cp.id')
|
||||||
|
// // ->join('policy_type pt', 'cp.policy_type_id = pt.id')
|
||||||
|
// // ->where('e.id', $emp_id)
|
||||||
|
// // ->where('e.emp_status', 'active')
|
||||||
|
// // ->where('ep.status', 'active')
|
||||||
|
// // ->where('e.is_active', 1)
|
||||||
|
// // ->where('ep.is_active', 1)
|
||||||
|
// // ->get()
|
||||||
|
// // ->getResultArray();
|
||||||
|
|
||||||
$headers = [
|
// $data = $db->table('employee_polices ep')
|
||||||
"Ocp-Apim-Subscription-Key: $subscriptionKey",
|
// ->select('pt.policy_type,
|
||||||
"apiver: $apiVersion",
|
// e.name, e.email_corporate as email, e.mobile as phone, e.emp_code as memberId, e.gender, e.dob, e.relationship as relation, e.id as employeeId
|
||||||
"mode: encrypt",
|
// cp.policy_no as policyNumber, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate, cp.wellness_plan_id as planId')
|
||||||
"Content-Type: application/json"
|
// ->join('employees e', 'e.id = ep.employee_id')
|
||||||
];
|
// ->join('client_policy cp', 'ep.client_policy_id = cp.id')
|
||||||
|
// ->join('policy_type pt', 'cp.policy_type_id = pt.id')
|
||||||
|
// ->where('ep.employee_id', $emp_id)
|
||||||
|
// ->where('ep.client_policy_id', $client_policy_id)
|
||||||
|
// ->where('ep.status', 'active')
|
||||||
|
// ->where('ep.is_active', 1)
|
||||||
|
// ->get()
|
||||||
|
// ->getRow();
|
||||||
|
|
||||||
$ch = curl_init($authUrl);
|
|
||||||
curl_setopt($ch, CURLOPT_POST, true);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
|
// $userParams = [];
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
// if(!empty($data))
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
// {
|
||||||
|
// $userParams['name'] = $data->name;
|
||||||
|
// $userParams['email'] = $data->email;
|
||||||
|
// $userParams['phone'] = $data->phone;
|
||||||
|
// $userParams['memberId'] = $data->employeeId; // memberId is unique primary key.
|
||||||
|
// $userParams['gender'] = $data->gender;
|
||||||
|
// $userParams['dob'] = $data->dob;
|
||||||
|
// $userParams['relation'] = $data->relation;
|
||||||
|
// $userParams['policyNumber'] = $data->policyNumber;
|
||||||
|
// $userParams['employeeId'] = $data->memberId;
|
||||||
|
// $userParams['policyStartDate']= $data->policyStartDate;
|
||||||
|
// $userParams['policyEndDate'] = $data->policyEndDate;
|
||||||
|
// $userParams['policyName'] = 'Nhance ' . $data->policy_type;
|
||||||
|
// $userParams['planId'] = $data->planId;
|
||||||
|
// $userParams['moduleName'] = 'home';
|
||||||
|
|
||||||
$apiResponse = curl_exec($ch);
|
// }
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
$curlError = curl_error($ch);
|
// // dd($userParams);
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
log_message('info', "SSO: API response received, HTTP Code: $httpCode");
|
|
||||||
|
|
||||||
// Check for cURL errors
|
// if (empty($userParams)) {
|
||||||
if ($curlError) {
|
// return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200);
|
||||||
log_message('error', "SSO: cURL error - $curlError");
|
// }
|
||||||
return ["error" => "cURL error: $curlError"];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check HTTP status
|
// // Derive 32-byte key from SHA256
|
||||||
if ($httpCode !== 200) {
|
// $derivedKey = hash('sha256', env('VISIT_SECRET_KEY'), true);
|
||||||
log_message('error', "SSO: HTTP error - Code: $httpCode, Response: $apiResponse");
|
|
||||||
return ["error" => "HTTP error: $httpCode", "response" => $apiResponse];
|
|
||||||
}
|
|
||||||
|
|
||||||
$jsonResponse = json_decode($apiResponse, true);
|
// // Build query string like Node.js
|
||||||
|
// $plainText = '';
|
||||||
// Check JSON decode error
|
// foreach ($userParams as $k => $v) {
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
// $plainText .= "&{$k}={$v}";
|
||||||
log_message('error', "SSO: JSON decode error - " . json_last_error_msg());
|
// }
|
||||||
return ["error" => "JSON decode error: " . json_last_error_msg(), "response" => $apiResponse];
|
// $plainText = ltrim($plainText, '&');
|
||||||
}
|
|
||||||
|
// // Encrypt
|
||||||
// Check API response status
|
// $algorithm = "aes-256-cbc";
|
||||||
if (!isset($jsonResponse["status"]) || $jsonResponse["status"] !== "success") {
|
// $encrypted = openssl_encrypt($plainText, $algorithm, $derivedKey, OPENSSL_RAW_DATA, env('VISIT_IV'));
|
||||||
log_message('error', "SSO: API error - " . json_encode($jsonResponse));
|
|
||||||
return ["error" => "API error", "response" => $jsonResponse];
|
// // Base64URL encode (same as Node.js output)
|
||||||
}
|
// $output = rtrim(strtr(base64_encode($encrypted), '+/', '-_'), '=');
|
||||||
|
|
||||||
if (!isset($jsonResponse["data"])) {
|
|
||||||
log_message('error', "SSO: Missing data field in response");
|
|
||||||
return ["error" => "Invalid API response - missing data field", "response" => $jsonResponse];
|
|
||||||
}
|
|
||||||
|
|
||||||
log_message('info', "SSO: API response validated successfully");
|
|
||||||
|
|
||||||
// ---------- STEP 4: Decrypt response ----------
|
|
||||||
log_message('info', "SSO: Starting response decryption");
|
|
||||||
|
|
||||||
$dataParts = explode(":", $jsonResponse["data"]);
|
|
||||||
|
|
||||||
if (count($dataParts) !== 2) {
|
|
||||||
log_message('error', "SSO: Invalid encrypted data format");
|
|
||||||
return ["error" => "Invalid encrypted data format", "data" => $jsonResponse["data"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
list($ivBase64, $cipherBase64) = $dataParts;
|
|
||||||
|
|
||||||
$respIv = base64_decode($ivBase64);
|
|
||||||
$respCipher = base64_decode($cipherBase64);
|
|
||||||
|
|
||||||
if ($respIv === false || $respCipher === false) {
|
|
||||||
log_message('error', "SSO: Base64 decode error");
|
|
||||||
return ["error" => "Base64 decode error"];
|
|
||||||
}
|
|
||||||
|
|
||||||
$decryptedJson = openssl_decrypt($respCipher, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $respIv);
|
|
||||||
|
|
||||||
if ($decryptedJson === false) {
|
|
||||||
log_message('error', "SSO: Decryption failed");
|
|
||||||
return ["error" => "Decryption failed"];
|
|
||||||
}
|
|
||||||
|
|
||||||
$decryptedData = json_decode($decryptedJson, true);
|
|
||||||
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
|
||||||
log_message('error', "SSO: Decrypted JSON decode error - " . json_last_error_msg());
|
|
||||||
return ["error" => "Decrypted JSON decode error: " . json_last_error_msg()];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($decryptedData["redirectUrl"])) {
|
|
||||||
log_message('error', "SSO: redirectUrl missing in decrypted data");
|
|
||||||
return ["error" => "redirectUrl missing", "decrypted" => $decryptedData];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- FINAL ----------
|
|
||||||
log_message('info', "SSO: Authentication successful, redirectUrl obtained");
|
|
||||||
return $decryptedData["redirectUrl"];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// $baseURL = env('VISIT_BASE_URL');
|
||||||
|
// $clientId = env('VISIT_CLIENT_ID');
|
||||||
|
// $finalUrl = $baseURL . '/sso?userParams=' . $output . '&clientId=' . $clientId;
|
||||||
|
|
||||||
|
// if (!empty($finalUrl)) {
|
||||||
|
// log_message('error', 'VISIT SSO | emp_id: '.$emp_id.' | URL: '.$finalUrl);
|
||||||
|
// return $this->respond(['status' => 'success','data' => $finalUrl], 200);
|
||||||
|
// } else {
|
||||||
|
// return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
// function getSSORedirectUrl($email = 'user@example.com')
|
// function getSSORedirectUrl($email = 'user@example.com')
|
||||||
|
|||||||
@ -28,11 +28,11 @@ class AppContentManagementController extends AdminController
|
|||||||
$this->feContentModel = new FEContentModel();
|
$this->feContentModel = new FEContentModel();
|
||||||
$this->clientModel = new ClientModel();
|
$this->clientModel = new ClientModel();
|
||||||
}
|
}
|
||||||
|
//listing
|
||||||
public function add_image_index()
|
public function add_image_index()
|
||||||
{
|
{
|
||||||
$this->myLogger->logme('error','Addvertisement Image list function called');
|
$headerData['tab_name'] = 'Advertisement Images';
|
||||||
$headerData['tab_name'] = 'Addvertisement Images';
|
$headerData['page_name'] = 'Advertisement Images';
|
||||||
$headerData['page_name'] = 'Addvertisement Images';
|
|
||||||
// $data['addImageList'] = $this->addImgModel->findAll();
|
// $data['addImageList'] = $this->addImgModel->findAll();
|
||||||
$data['addImageList'] = $this->addImgModel->select('advertisement_images.*,
|
$data['addImageList'] = $this->addImgModel->select('advertisement_images.*,
|
||||||
clients.client_name,
|
clients.client_name,
|
||||||
@ -42,7 +42,7 @@ class AppContentManagementController extends AdminController
|
|||||||
->where('advertisement_images.is_active', 1)
|
->where('advertisement_images.is_active', 1)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$data['client'] = $this->clientModel->where('is_active', 1)->findAll();
|
$data['client'] = $this->clientModel->where('is_active', 1)->where('client_type', 1)->findAll();
|
||||||
|
|
||||||
// dd($data);
|
// dd($data);
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class AppContentManagementController extends AdminController
|
|||||||
// $this->loadLayout('client_onboarding', $data);
|
// $this->loadLayout('client_onboarding', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// using add and edit
|
// add and edit
|
||||||
public function add_advertise_image() {
|
public function add_advertise_image() {
|
||||||
try {
|
try {
|
||||||
$file = $this->request->getFile('advertise_image');
|
$file = $this->request->getFile('advertise_image');
|
||||||
@ -70,7 +70,8 @@ class AppContentManagementController extends AdminController
|
|||||||
return $this->respond(['status' => false, 'message' => 'No file uploaded or invalid file.'], 400);
|
return $this->respond(['status' => false, 'message' => 'No file uploaded or invalid file.'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$uploadPath = WRITEPATH . 'uploads/advertiseImage/';
|
// $uploadPath = WRITEPATH . 'uploads/advertiseImage/';
|
||||||
|
$uploadPath = ROOTPATH . 'public/uploads/add_image_upload/';
|
||||||
if (!is_dir($uploadPath)) mkdir($uploadPath, 0755, true);
|
if (!is_dir($uploadPath)) mkdir($uploadPath, 0755, true);
|
||||||
|
|
||||||
|
|
||||||
@ -91,6 +92,7 @@ class AppContentManagementController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// soft delete
|
||||||
public function remove_advertise_image()
|
public function remove_advertise_image()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -111,47 +113,34 @@ class AppContentManagementController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public function showAdvertiseImage($fileName)
|
// Preview image Went Edit.
|
||||||
// {
|
|
||||||
|
|
||||||
// $filePath = WRITEPATH . 'uploads/advertiseImage/' . $fileName;
|
|
||||||
|
|
||||||
// if (!file_exists($filePath)) {
|
|
||||||
// return $this->response->setStatusCode(404, 'File not found');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $mimeType = mime_content_type($filePath);
|
|
||||||
// header('Content-Type: ' . $mimeType);
|
|
||||||
// readfile($filePath);
|
|
||||||
// exit;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// In AppContentManagementController.php (This is what needs to be fixed if the direct path fails)
|
|
||||||
|
|
||||||
public function showAdvertiseImage($filename)
|
public function showAdvertiseImage($filename)
|
||||||
{
|
{
|
||||||
$path = WRITEPATH . 'uploads/advertiseImage/' . $filename;
|
// $path = WRITEPATH . 'uploads/advertiseImage/' . $filename;
|
||||||
|
$path = ROOTPATH . 'public/uploads/add_image_upload/' . $filename;
|
||||||
|
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||||
|
// return $this->response->setStatusCode(404, 'File not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$mime = mime_content_type($path);
|
$mime = mime_content_type($path);
|
||||||
|
// header('Content-Type: ' . $mimeType);
|
||||||
|
// readfile($path);
|
||||||
|
// exit;
|
||||||
return $this->response->setHeader('Content-Type', $mime)->setBody(file_get_contents($path));
|
return $this->response->setHeader('Content-Type', $mime)->setBody(file_get_contents($path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getAdvertiseImage($image_id){
|
// public function getAdvertiseImage($image_id){
|
||||||
|
// $image_data = $this->addImgModel->select('name')->where(['id' => $image_id])->first();
|
||||||
$image_data = $this->addImgModel->select('name')->where(['id' => $image_id])->first();
|
// if($image_data){
|
||||||
|
// return $image_data['name'];
|
||||||
if($image_data){
|
// }else{
|
||||||
return $image_data['name'];
|
// return ;
|
||||||
}else{
|
// }
|
||||||
return ;
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2308,6 +2308,10 @@ class EmployeeController extends AdminController
|
|||||||
}
|
}
|
||||||
$message = isset($message) ? ($message . ' not defined for choosed policy') : null;
|
$message = isset($message) ? ($message . ' not defined for choosed policy') : null;
|
||||||
|
|
||||||
|
if ($policy_details['cd_ac_pk'] == null) {
|
||||||
|
$message = isset($message) ? ($message . ' The policy does not have a CD account number.') : null;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message, 'si_enhancement' => $si_enhancement_true_or_false, 'insurer_multi_event' => $insurer_details['is_multi_event'], 'tpa_api_service_status' => $tpa_api_service_status], 200);
|
return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message, 'si_enhancement' => $si_enhancement_true_or_false, 'insurer_multi_event' => $insurer_details['is_multi_event'], 'tpa_api_service_status' => $tpa_api_service_status], 200);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2592,7 +2592,7 @@ class EmployeeRestController extends AdminController
|
|||||||
// print_r($ticketHistory); die;
|
// print_r($ticketHistory); die;
|
||||||
|
|
||||||
$currentClaimStatus = $this->claimStatusModel->select("claim_status")->where('id', $data['claims_data']['claim_status_id'])->where('is_active', 1)->first();
|
$currentClaimStatus = $this->claimStatusModel->select("claim_status")->where('id', $data['claims_data']['claim_status_id'])->where('is_active', 1)->first();
|
||||||
$ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('is_active', 1)->findAll();
|
$ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('ticket_type', $data['claims_data']['ticket_type_id'])->where('is_active', 1)->findAll();
|
||||||
$status_list = array_column($ticketClaimStatus, 'display_name', 'claim_status');
|
$status_list = array_column($ticketClaimStatus, 'display_name', 'claim_status');
|
||||||
// print_r($currentClaimStatus); die;
|
// print_r($currentClaimStatus); die;
|
||||||
|
|
||||||
@ -3028,7 +3028,8 @@ class EmployeeRestController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$emp_reatail_policy_data = $this->getEmpRetailPolicy($employeeSelfData);
|
$emp_reatail_policy_data = $this->getEmpRetailPolicy($employeeSelfData);
|
||||||
$emp_wellness_data = $this->getWellnessUrl($employeeSelfData->id ?? null);
|
$apiServiceController = new ApiServiceController;
|
||||||
|
$emp_wellness_data = $apiServiceController->getWellnessUrl($employeeSelfData->id ?? null);
|
||||||
|
|
||||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result, 'emp_name' => $employeeName, 'pre_policy_count' => $prePolicyCount, 'emp_not_enrolled_count' => $empNotEnrolledCount, 'retail_policy_data' => $emp_reatail_policy_data, 'wellness_data' => $emp_wellness_data], 200);
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result, 'emp_name' => $employeeName, 'pre_policy_count' => $prePolicyCount, 'emp_not_enrolled_count' => $empNotEnrolledCount, 'retail_policy_data' => $emp_reatail_policy_data, 'wellness_data' => $emp_wellness_data], 200);
|
||||||
} else {
|
} else {
|
||||||
@ -3176,32 +3177,58 @@ class EmployeeRestController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function getAdvertisementImage_old()
|
||||||
|
// {
|
||||||
|
// try {
|
||||||
|
|
||||||
|
// $client_id = $this->request->getGet('client_id');
|
||||||
|
|
||||||
|
// $img = $this->addImgModel->where('is_active', 1)->where('client_id',$client_id)->findAll();
|
||||||
|
|
||||||
|
// if (count($img) > 0) {
|
||||||
|
// $data = [];
|
||||||
|
// foreach ($img as $key => $value) {
|
||||||
|
// $url = base_url('public/uploads/add_image_upload/') . $value['name'];
|
||||||
|
// array_push($data, $url);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return $this->respond(['status' => 'success', 'code' => 200, 'data' => $data], 200);
|
||||||
|
// } else {
|
||||||
|
|
||||||
|
// return $this->respond(['status' => 'failed', 'code' => 404, 'data' => 'No Data'], 404);
|
||||||
|
// }
|
||||||
|
// } catch (\Throwable $th) {
|
||||||
|
// return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public function getAdvertisementImage()
|
public function getAdvertisementImage()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$client_id = $this->request->getGet('client_id');
|
$client_id = $this->request->getGet('client_id');
|
||||||
|
// get client_id & convert empty/null/undefined → 0
|
||||||
|
// $client_id = ($client_id === null || $client_id === '' || $client_id === 'undefined') ? 0 : $client_id;
|
||||||
|
|
||||||
$img = $this->addImgModel->where('is_active', 1)->where('client_id',$client_id)->findAll();
|
// fetch images for client
|
||||||
|
$images = $this->addImgModel->where('is_active', 1)->where('client_id', $client_id)->findAll();
|
||||||
|
|
||||||
if (count($img) > 0) {
|
// if no client images → load default client 0
|
||||||
$data = [];
|
if (count($images) == 0) {
|
||||||
foreach ($img as $key => $value) {
|
$images = $this->addImgModel->where('is_active', 1)->where('client_id', 0)->findAll();
|
||||||
$url = base_url('public/uploads/add_image_upload/') . $value['name'];
|
|
||||||
array_push($data, $url);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $data], 200);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => 'No Data'], 404);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prepare URLs
|
||||||
|
$data = array_map(function($img){ return base_url('public/uploads/add_image_upload/' . $img['name']); }, $images);
|
||||||
|
|
||||||
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $data], 200);
|
||||||
|
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
|
||||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
|
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function storeFireBase()
|
public function storeFireBase()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -5012,81 +5039,7 @@ class EmployeeRestController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWellnessUrl($emp_id)
|
|
||||||
{
|
|
||||||
// $emp_id = $this->request->getGet('emp_id');
|
|
||||||
|
|
||||||
$db = \Config\Database::connect();
|
|
||||||
$data = $db->table('employees e')
|
|
||||||
->select('pt.policy_type,
|
|
||||||
e.name, e.email_corporate as email, e.mobile as phone, e.emp_code as memberId, e.gender, e.dob, e.relationship as relation,
|
|
||||||
cp.policy_no as policyNumber, ep.employee_id as employeeId, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate , cp.wellness_plan_id as planId')
|
|
||||||
->join('employee_polices ep', 'e.id = ep.employee_id')
|
|
||||||
->join('client_policy cp', 'ep.client_policy_id = cp.id')
|
|
||||||
->join('policy_type pt', 'cp.policy_type_id = pt.id')
|
|
||||||
->where('e.id', $emp_id)
|
|
||||||
->where('e.emp_status', 'active')
|
|
||||||
->where('ep.status', 'active')
|
|
||||||
->where('e.is_active', 1)
|
|
||||||
->where('ep.is_active', 1)
|
|
||||||
->get()
|
|
||||||
->getResultArray();
|
|
||||||
|
|
||||||
|
|
||||||
$userParams = [];
|
|
||||||
foreach ($data as $row) {
|
|
||||||
if ($row['planId'] != null) {
|
|
||||||
$userParams['name'] = $row['name'];
|
|
||||||
$userParams['email'] = $row['email'];
|
|
||||||
$userParams['phone'] = $row['phone'];
|
|
||||||
$userParams['memberId'] = $row['employeeId']; // memberId is unique primary key.
|
|
||||||
$userParams['gender'] = $row['gender'];
|
|
||||||
$userParams['dob'] = $row['dob'];
|
|
||||||
$userParams['relation'] = $row['relation'];
|
|
||||||
$userParams['policyNumber'] = $row['policyNumber'];
|
|
||||||
$userParams['employeeId'] = $row['memberId'];
|
|
||||||
$userParams['policyStartDate']= $row['policyStartDate'];
|
|
||||||
$userParams['policyEndDate'] = $row['policyEndDate'];
|
|
||||||
$userParams['policyName'] = $row['policy_type'];
|
|
||||||
$userParams['planId'] = $row['planId'];
|
|
||||||
$userParams['moduleName'] = 'home';
|
|
||||||
break; // stop after first GMC match
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($userParams)) {
|
|
||||||
return ['status' => 'failed','message' => 'Coming soon........!'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// echo 'coming';die();
|
|
||||||
// Derive 32-byte key from SHA256
|
|
||||||
$derivedKey = hash('sha256', env('VISIT_SECRET_KEY'), true);
|
|
||||||
|
|
||||||
// Build query string like Node.js
|
|
||||||
$plainText = '';
|
|
||||||
foreach ($userParams as $k => $v) {
|
|
||||||
$plainText .= "&{$k}={$v}";
|
|
||||||
}
|
|
||||||
$plainText = ltrim($plainText, '&');
|
|
||||||
|
|
||||||
// Encrypt
|
|
||||||
$algorithm = "aes-256-cbc";
|
|
||||||
$encrypted = openssl_encrypt($plainText, $algorithm, $derivedKey, OPENSSL_RAW_DATA, env('VISIT_IV'));
|
|
||||||
|
|
||||||
// Base64URL encode (same as Node.js output)
|
|
||||||
$output = rtrim(strtr(base64_encode($encrypted), '+/', '-_'), '=');
|
|
||||||
|
|
||||||
$baseURL = env('VISIT_BASE_URL');
|
|
||||||
$clientId = env('VISIT_CLIENT_ID');
|
|
||||||
$finalUrl = $baseURL . '/sso?userParams=' . $output . '&clientId=' . $clientId;
|
|
||||||
|
|
||||||
if (!empty($finalUrl)) {
|
|
||||||
log_message('error', 'VISIT SSO | emp_id: '.$emp_id.' | URL: '.$finalUrl);
|
|
||||||
return ['status' => 'success','data' => $finalUrl];
|
|
||||||
} else {
|
|
||||||
return ['status' => 'failed','message' => 'Coming soon........!'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPolicyTypeAndInsurer()
|
public function getPolicyTypeAndInsurer()
|
||||||
{
|
{
|
||||||
|
|||||||
259
app/Controllers/LogController.php
Normal file
259
app/Controllers/LogController.php
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers;
|
||||||
|
use CodeIgniter\Controller;
|
||||||
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
|
class LogController extends BaseController
|
||||||
|
{
|
||||||
|
private $logPath;
|
||||||
|
public $dModel;
|
||||||
|
public $session;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Path to log files
|
||||||
|
$this->logPath = WRITEPATH . 'logs/';
|
||||||
|
$this->session = session();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display list of all log files
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
|
||||||
|
$logFiles = $this->getLogFiles();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'title' => 'Log Files',
|
||||||
|
'logFiles' => $logFiles
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->loadLayout('logs/index', $data);
|
||||||
|
|
||||||
|
// return view('logs/index', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all log files sorted by date (latest first)
|
||||||
|
*/
|
||||||
|
private function getLogFiles()
|
||||||
|
{
|
||||||
|
$files = [];
|
||||||
|
|
||||||
|
if (!is_dir($this->logPath)) {
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
$iterator = new \DirectoryIterator($this->logPath);
|
||||||
|
|
||||||
|
foreach ($iterator as $fileInfo) {
|
||||||
|
if ($fileInfo->isFile() && $fileInfo->getExtension() === 'log') {
|
||||||
|
$files[] = [
|
||||||
|
'name' => $fileInfo->getFilename(),
|
||||||
|
'path' => $fileInfo->getPathname(),
|
||||||
|
'size' => $this->formatBytes($fileInfo->getSize()),
|
||||||
|
'modified' => $fileInfo->getMTime(),
|
||||||
|
'modified_date' => date('Y-m-d H:i:s', $fileInfo->getMTime())
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by modified time (latest first)
|
||||||
|
usort($files, function($a, $b) {
|
||||||
|
return $b['modified'] - $a['modified'];
|
||||||
|
});
|
||||||
|
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View specific log file content
|
||||||
|
*/
|
||||||
|
public function view($filename = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!$filename) {
|
||||||
|
return redirect()->to('/logs')->with('error', 'No log file specified');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Security: prevent directory traversal
|
||||||
|
$filename = basename($filename);
|
||||||
|
$filePath = $this->logPath . $filename;
|
||||||
|
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
return redirect()->to('/logs')->with('error', 'Log file not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ extract date from filename: log-YYYY-MM-DD.log
|
||||||
|
if (preg_match('/log-(\d{4}-\d{2}-\d{2})\.log/', $filename, $match)) {
|
||||||
|
$currentDate = $match[1];
|
||||||
|
|
||||||
|
$prevDate = date('Y-m-d', strtotime('-1 day', strtotime($currentDate)));
|
||||||
|
$nextDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
|
||||||
|
|
||||||
|
$prevFile = "log-$prevDate.log";
|
||||||
|
$nextFile = "log-$nextDate.log";
|
||||||
|
|
||||||
|
$prevExists = file_exists($this->logPath . $prevFile);
|
||||||
|
$nextExists = file_exists($this->logPath . $nextFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read log file content
|
||||||
|
$content = file_get_contents($filePath);
|
||||||
|
$logEntries = $this->parseLogFile($content);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'title' => 'View Log: ' . $filename,
|
||||||
|
'filename' => $filename,
|
||||||
|
'logEntries' => $logEntries,
|
||||||
|
'prevFile' => $prevExists ? $prevFile : null,
|
||||||
|
'nextFile' => $nextExists ? $nextFile : null,
|
||||||
|
'fileSize' => $this->formatBytes(filesize($filePath)),
|
||||||
|
'lastModified' => date('Y-m-d H:i:s', filemtime($filePath))
|
||||||
|
];
|
||||||
|
|
||||||
|
// print_r( $data); die;
|
||||||
|
|
||||||
|
return $this->loadLayout('logs/view', $data);
|
||||||
|
// return view('logs/view', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse log file into structured array
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function parseLogFile($content)
|
||||||
|
{
|
||||||
|
$entries = [];
|
||||||
|
$lines = explode("\n", $content);
|
||||||
|
|
||||||
|
$currentEntry = null;
|
||||||
|
|
||||||
|
// Messages to filter out
|
||||||
|
$skipPatterns = [
|
||||||
|
'/Session: Class initialized using/',
|
||||||
|
'/Session class already loaded/',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
// Match CI4 log format: LEVEL - date --> message
|
||||||
|
if (preg_match('/^(\w+)\s*-\s*(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s*-->\s*(.*)$/', $line, $matches)) {
|
||||||
|
|
||||||
|
// Save previous entry if exists (before checking skip)
|
||||||
|
if ($currentEntry !== null) {
|
||||||
|
$entries[] = $currentEntry;
|
||||||
|
$currentEntry = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if this message should be skipped
|
||||||
|
$shouldSkip = false;
|
||||||
|
foreach ($skipPatterns as $pattern) {
|
||||||
|
if (preg_match($pattern, $matches[3])) {
|
||||||
|
$shouldSkip = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($shouldSkip) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start new entry
|
||||||
|
$currentEntry = [
|
||||||
|
'level' => $matches[1],
|
||||||
|
'date' => $matches[2],
|
||||||
|
'message' => $matches[3]
|
||||||
|
];
|
||||||
|
} elseif ($currentEntry !== null && trim($line) !== '') {
|
||||||
|
// Continuation of previous message
|
||||||
|
$currentEntry['message'] .= "\n" . $line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add last entry
|
||||||
|
if ($currentEntry !== null) {
|
||||||
|
$entries[] = $currentEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_reverse($entries); // Latest first
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download log file
|
||||||
|
*/
|
||||||
|
public function download($filename = null)
|
||||||
|
{
|
||||||
|
if (!$filename) {
|
||||||
|
return redirect()->to('/logs')->with('error', 'No log file specified');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = basename($filename);
|
||||||
|
$filePath = $this->logPath . $filename;
|
||||||
|
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
return redirect()->to('/logs')->with('error', 'Log file not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->download($filePath, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete log file
|
||||||
|
*/
|
||||||
|
public function delete($filename = null)
|
||||||
|
{
|
||||||
|
if (!$filename) {
|
||||||
|
return redirect()->to('/logs')->with('error', 'No log file specified');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = basename($filename);
|
||||||
|
$filePath = $this->logPath . $filename;
|
||||||
|
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
return redirect()->to('/logs')->with('error', 'Log file not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlink($filePath)) {
|
||||||
|
return redirect()->to('/logs')->with('success', 'Log file deleted successfully');
|
||||||
|
} else {
|
||||||
|
return redirect()->to('/logs')->with('error', 'Failed to delete log file');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format bytes to human readable format
|
||||||
|
*/
|
||||||
|
private function formatBytes($bytes, $precision = 2)
|
||||||
|
{
|
||||||
|
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||||
|
|
||||||
|
$bytes = max($bytes, 0);
|
||||||
|
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||||
|
$pow = min($pow, count($units) - 1);
|
||||||
|
|
||||||
|
$bytes /= pow(1024, $pow);
|
||||||
|
|
||||||
|
return round($bytes, $precision) . ' ' . $units[$pow];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all log files
|
||||||
|
*/
|
||||||
|
public function clearAll()
|
||||||
|
{
|
||||||
|
$logFiles = $this->getLogFiles();
|
||||||
|
$deleted = 0;
|
||||||
|
|
||||||
|
foreach ($logFiles as $file) {
|
||||||
|
if (unlink($file['path'])) {
|
||||||
|
$deleted++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->to('/logs')->with('success', $deleted . ' log file(s) deleted successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -150,7 +150,7 @@ class MediAssistApiController extends BaseController
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log_message('error', 'TPA CLAIM PUSH SUCCESS BUT claimReferenceNo EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
log_message('error', 'TPA CLAIM PUSH API SUCCESS BUT claimReferenceNo EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ class MediAssistApiController extends BaseController
|
|||||||
$client_policy_id = $requestData['client_policy_id'] ?? null;
|
$client_policy_id = $requestData['client_policy_id'] ?? null;
|
||||||
|
|
||||||
if (empty($policyNo)) {
|
if (empty($policyNo)) {
|
||||||
log_message('error', 'GetBenefDetails: policy_no missing in request');
|
log_message('error', 'TPA ID PULL | policy_no missing in request');
|
||||||
if($function_calling_type == "job"){
|
if($function_calling_type == "job"){
|
||||||
return ['status' => false, 'message' => 'policy_no required'];
|
return ['status' => false, 'message' => 'policy_no required'];
|
||||||
}else{
|
}else{
|
||||||
@ -232,7 +232,7 @@ class MediAssistApiController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (empty($client_policy_id)) {
|
if (empty($client_policy_id)) {
|
||||||
log_message('error', 'GetBenefDetails: client_policy_id missing in request');
|
log_message('error', 'TPA ID PULL | client_policy_id missing in request');
|
||||||
if($function_calling_type == "job"){
|
if($function_calling_type == "job"){
|
||||||
return ['status' => false, 'message' => 'client_policy_id required'];
|
return ['status' => false, 'message' => 'client_policy_id required'];
|
||||||
}else{
|
}else{
|
||||||
@ -240,8 +240,7 @@ class MediAssistApiController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message('error', "GetBenefDetails called for policy_no: {$policyNo}");
|
log_message('error', "TPA ID PULL | called for policy_no: {$policyNo} , client_policy_id: {$client_policy_id}");
|
||||||
log_message('error', "GetBenefDetails called for client_policy_id: {$client_policy_id}");
|
|
||||||
|
|
||||||
$employeePolicyModel = new EmployeePolicyModel();
|
$employeePolicyModel = new EmployeePolicyModel();
|
||||||
$employeePolicyData = $employeePolicyModel
|
$employeePolicyData = $employeePolicyModel
|
||||||
@ -260,7 +259,7 @@ class MediAssistApiController extends BaseController
|
|||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
if (empty($employeePolicyData)) {
|
if (empty($employeePolicyData)) {
|
||||||
log_message('error', 'GetBenefDetails: employeePolicyData is empty');
|
log_message('error', 'TPA ID PULL FAILED | employeePolicyData is empty (tpa_id IS NULL from nhance) for this tpa id pull request');
|
||||||
if($function_calling_type == "job"){
|
if($function_calling_type == "job"){
|
||||||
return ['status' => false, 'message' => 'employeePolicyData not found'];
|
return ['status' => false, 'message' => 'employeePolicyData not found'];
|
||||||
}else{
|
}else{
|
||||||
@ -284,8 +283,8 @@ class MediAssistApiController extends BaseController
|
|||||||
"employeeId" => ""
|
"employeeId" => ""
|
||||||
];
|
];
|
||||||
|
|
||||||
log_message('error', "GetBenefDetails API Request (startIndex={$startIndex}): " . json_encode($body));
|
log_message('error', "TPA ID PULL | API Request (startIndex={$startIndex}): " . json_encode($body));
|
||||||
log_message('error', "GetBenefDetails API parems " . json_encode([$url, $method, $headers, $body]));
|
log_message('error', "TPA ID PULL | API parems " . json_encode([$url, $method, $headers, $body]));
|
||||||
|
|
||||||
$response = call_third_party_api($url, $method, $headers, $body);
|
$response = call_third_party_api($url, $method, $headers, $body);
|
||||||
|
|
||||||
@ -300,7 +299,7 @@ class MediAssistApiController extends BaseController
|
|||||||
log_message('error', "Failed to update file table status.");
|
log_message('error', "Failed to update file table status.");
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message('error', 'GetBenefDetails API failed: ' . json_encode($response));
|
log_message('error', 'TPA ID PULL API FAILED | API failed: ' . json_encode($response));
|
||||||
|
|
||||||
if($function_calling_type == "job"){
|
if($function_calling_type == "job"){
|
||||||
return ['status' => false, 'message' => 'API call failed', 'data' => $response];
|
return ['status' => false, 'message' => 'API call failed', 'data' => $response];
|
||||||
@ -312,7 +311,7 @@ class MediAssistApiController extends BaseController
|
|||||||
$data = $response['data'] ?? [];
|
$data = $response['data'] ?? [];
|
||||||
|
|
||||||
if (!isset($data['benefDetails'])) {
|
if (!isset($data['benefDetails'])) {
|
||||||
log_message('error', "GetBenefDetails: 'benefDetails' missing in API response: " . json_encode($data));
|
log_message('error', "TPA ID PULL FAILED |: 'benefDetails' missing in API response: " . json_encode($data));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,7 +405,7 @@ class MediAssistApiController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
log_message('error', "GetBenefDetails completed. Total fetched={$totalCount}, updated={$updated}");
|
log_message('error', "TPA ID PULL SUCCESS | completed. Total fetched={$totalCount}, updated={$updated}");
|
||||||
|
|
||||||
if($function_calling_type == "job"){
|
if($function_calling_type == "job"){
|
||||||
return [
|
return [
|
||||||
@ -532,7 +531,7 @@ class MediAssistApiController extends BaseController
|
|||||||
$response = call_third_party_api($url, $method, $headers, $body);
|
$response = call_third_party_api($url, $method, $headers, $body);
|
||||||
|
|
||||||
if ($response['status'] != true || empty($response['data']['claimsData'][0])) {
|
if ($response['status'] != true || empty($response['data']['claimsData'][0])) {
|
||||||
log_message('error', 'Claim status API failed for ticket ID: ' . $claimId);
|
log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
|
||||||
|
|
||||||
return $this->response->setJSON([
|
return $this->response->setJSON([
|
||||||
'status' => false,
|
'status' => false,
|
||||||
@ -598,7 +597,7 @@ class MediAssistApiController extends BaseController
|
|||||||
$this->db->table('ticket_master')->where('id', $claimId)->update($updateArray);
|
$this->db->table('ticket_master')->where('id', $claimId)->update($updateArray);
|
||||||
|
|
||||||
// LOG UPDATE
|
// LOG UPDATE
|
||||||
log_message('info', "Updated ticket ID $claimId with claim status: $currentStatus");
|
log_message('info', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||||
|
|
||||||
return $this->response->setJSON([
|
return $this->response->setJSON([
|
||||||
'status' => true,
|
'status' => true,
|
||||||
@ -633,10 +632,10 @@ class MediAssistApiController extends BaseController
|
|||||||
if (!$ticket || empty($ticket['ClaimID'])) {
|
if (!$ticket || empty($ticket['ClaimID'])) {
|
||||||
log_message('error', "IRSubmission FAILED → ClaimID NOT FOUND for ticket_id={$claimId}");
|
log_message('error', "IRSubmission FAILED → ClaimID NOT FOUND for ticket_id={$claimId}");
|
||||||
|
|
||||||
return $this->response->setJSON([
|
return [
|
||||||
'status' => false,
|
'status' => false,
|
||||||
'message' => "ClaimID not found for ticket {$claimId}"
|
'message' => "ClaimID not found for ticket {$claimId}"
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. FETCH IR ATTACHMENTS
|
// 2. FETCH IR ATTACHMENTS
|
||||||
|
|||||||
@ -7,15 +7,18 @@ use CodeIgniter\HTTP\ResponseInterface;
|
|||||||
|
|
||||||
class VidalApiController extends BaseController
|
class VidalApiController extends BaseController
|
||||||
{
|
{
|
||||||
public function index()
|
protected $db;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
//
|
$this->db = \Config\Database::connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function uploadFileToVidal($filePath,$filename)
|
function uploadFileToVidal($filePath,$filename)
|
||||||
{
|
{
|
||||||
$apiUrl = "https://devapigw.vidalhealthtpa.com/partner-integration/api/files/upload-url";
|
// $apiUrl = "https://devapigw.vidalhealthtpa.com/partner-integration/api/files/upload-url";
|
||||||
|
$apiUrl = getenv('VIDAL_API_BASE_URL').'/files/upload-url';
|
||||||
$subscriptionKey = getenv('VIDAL_API_SUBSCRIPTION_KEY');
|
$subscriptionKey = getenv('VIDAL_API_SUBSCRIPTION_KEY');
|
||||||
|
|
||||||
log_message('error', "Starting file upload process for filename: $filename | Path: $filePath");
|
log_message('error', "Starting file upload process for filename: $filename | Path: $filePath");
|
||||||
@ -105,10 +108,8 @@ class VidalApiController extends BaseController
|
|||||||
{
|
{
|
||||||
helper('api');
|
helper('api');
|
||||||
|
|
||||||
//Prepare body data
|
|
||||||
$db = \Config\Database::connect();
|
|
||||||
// Fetch the data from DB
|
// Fetch the data from DB
|
||||||
$data = $db->table('ticket_master tm')
|
$data = $this->db->table('ticket_master tm')
|
||||||
->select('
|
->select('
|
||||||
tm.id,
|
tm.id,
|
||||||
tm.emp_mobile as mobileNo,
|
tm.emp_mobile as mobileNo,
|
||||||
@ -116,9 +117,14 @@ class VidalApiController extends BaseController
|
|||||||
tm.doa as admissionDate,
|
tm.doa as admissionDate,
|
||||||
tm.dod as dischargeDate,
|
tm.dod as dischargeDate,
|
||||||
tm.hospital_name as hospitalName,
|
tm.hospital_name as hospitalName,
|
||||||
|
tm.hospital_address as hospitalAddress,
|
||||||
|
tm.hospital_state as hospitalState,
|
||||||
|
tm.hospital_city as hospitalCity,
|
||||||
|
tm.hospital_pin_code as hospitalPinCode,
|
||||||
|
tm.hospital_phone_no as hospitalPhoneNo,
|
||||||
tm.claim_amount as requestedAmount,
|
tm.claim_amount as requestedAmount,
|
||||||
|
tm.tpa_no as dependentUniqueId,
|
||||||
cp.policy_no as policyNo,
|
cp.policy_no as policyNo,
|
||||||
e.id as dependentUniqueIdOld,
|
|
||||||
e.emp_code as memberId,
|
e.emp_code as memberId,
|
||||||
tn.note as disease,
|
tn.note as disease,
|
||||||
tn.note as reasonForHospitalization,
|
tn.note as reasonForHospitalization,
|
||||||
@ -126,7 +132,7 @@ class VidalApiController extends BaseController
|
|||||||
cf.url as filePath,
|
cf.url as filePath,
|
||||||
pt.policy_type as typeOfClaim,
|
pt.policy_type as typeOfClaim,
|
||||||
ep.tpa_id as empanelmentNo,
|
ep.tpa_id as empanelmentNo,
|
||||||
ep.tpa_id as dependentUniqueId,
|
|
||||||
')
|
')
|
||||||
->join('employees e', 'e.id = tm.emp_id', 'left')
|
->join('employees e', 'e.id = tm.emp_id', 'left')
|
||||||
->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
|
->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
|
||||||
@ -196,7 +202,9 @@ class VidalApiController extends BaseController
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
// dd($body);
|
// dd($body);
|
||||||
log_message('error', "Submit claim failed - payload ". json_encode($body ));
|
|
||||||
|
log_message('error', 'TPA CLAIM PUSH | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||||
|
|
||||||
// $body = [
|
// $body = [
|
||||||
// 'policyNo' => "351500/D0534/PP/20-20/PC",
|
// 'policyNo' => "351500/D0534/PP/20-20/PC",
|
||||||
// 'dependentUniqueId' => "EN000000182-C-41",
|
// 'dependentUniqueId' => "EN000000182-C-41",
|
||||||
@ -227,16 +235,175 @@ class VidalApiController extends BaseController
|
|||||||
$response = call_third_party_api($url, $method, $headers, $body);
|
$response = call_third_party_api($url, $method, $headers, $body);
|
||||||
|
|
||||||
if($response['status'] != true){
|
if($response['status'] != true){
|
||||||
return $this->response->setJSON([
|
log_message('error', 'TPA CLAIM PUSH FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||||
'status' => false,
|
return;
|
||||||
'message' => 'failed.',
|
|
||||||
'data' => $response
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->setJSON($response);
|
// return $this->response->setJSON($response);
|
||||||
|
|
||||||
|
if($response['data']['status'] == 'SUCCESS')
|
||||||
|
{
|
||||||
|
$claimNO = $response['data']['data']['claimNO'] ?? null;
|
||||||
|
$claimInwardNO = $response['data']['data']['claimInwardNO'] ?? null;
|
||||||
|
|
||||||
|
if(!empty($claimNO) && !empty($claimInwardNO)){
|
||||||
|
|
||||||
|
log_message('error', 'TPA CLAIM PUSH SUCCESS | claimId: '.$claimId.' | claimNO: '.$claimNO.' | claimInwardNO: '.$claimInwardNO);
|
||||||
|
|
||||||
|
$this->db->table('ticket_master')
|
||||||
|
->where('id',$claimId)
|
||||||
|
->update([ 'tpa_claim_push_reference_no' => $claimInwardNO , 'tpa_claim_id' => $claimNO ]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log_message('error', 'TPA CLAIM PUSH API SUCCESS BUT claimNO,claimInwardNO EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
log_message('error', 'TPA CLAIM PUSH API FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getWellnessSSORedirectUrl($email = 'test@getvisitapp.com')
|
||||||
|
{
|
||||||
|
log_message('info', "SSO: Starting authentication for email: $email");
|
||||||
|
|
||||||
|
// ---------- CONFIG ----------
|
||||||
|
$authUrl = env('VIDAL_WELLNESS_BASE_URL');
|
||||||
|
$subscriptionKey = env('VIDAL_WELLNESS_SUBSCRIPTION_KEY');
|
||||||
|
$apiVersion = "1";
|
||||||
|
|
||||||
|
// Provided Base64 AES key
|
||||||
|
$base64Key = env('VIDAL_WELLNESS_BASE64_KEY');
|
||||||
|
$key = base64_decode($base64Key);
|
||||||
|
|
||||||
|
log_message('info', "SSO: Config loaded, Auth URL: $authUrl");
|
||||||
|
|
||||||
|
// ---------- STEP 1: Build plaintext payload ----------
|
||||||
|
$plainPayload = json_encode([
|
||||||
|
"email" => $email,
|
||||||
|
// "corporateId" => env('VIDAL_WELLNESS_CORPORATE_ID'),
|
||||||
|
"urlIdentifier" => env('VIDAL_WELLNESS_URL_IDENTIFIER')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// ---------- STEP 2: Encrypt payload ----------
|
||||||
|
$iv = random_bytes(16);
|
||||||
|
$encryptedRaw = openssl_encrypt($plainPayload, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $iv);
|
||||||
|
|
||||||
|
$encryptedPayload = base64_encode($iv) . ":" . base64_encode($encryptedRaw);
|
||||||
|
|
||||||
|
log_message('info', "SSO: Payload encrypted successfully");
|
||||||
|
|
||||||
|
// ---------- STEP 3: Call Authentication API ----------
|
||||||
|
$requestBody = json_encode([
|
||||||
|
"payload" => $encryptedPayload,
|
||||||
|
"source" => env('VIDAL_WELLNESS_SUB_PARTNER_ID'),
|
||||||
|
"subPartnerId" => env('VIDAL_WELLNESS_SUB_PARTNER_ID')
|
||||||
|
]);
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
"Ocp-Apim-Subscription-Key: $subscriptionKey",
|
||||||
|
"apiver: $apiVersion",
|
||||||
|
"mode: encrypt",
|
||||||
|
"Content-Type: application/json"
|
||||||
|
];
|
||||||
|
|
||||||
|
$ch = curl_init($authUrl);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
|
$apiResponse = curl_exec($ch);
|
||||||
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$curlError = curl_error($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
log_message('info', "SSO: API response received, HTTP Code: $httpCode");
|
||||||
|
|
||||||
|
// Check for cURL errors
|
||||||
|
if ($curlError) {
|
||||||
|
log_message('error', "SSO: cURL error - $curlError");
|
||||||
|
return ['status' => 'failed','message' => $curlError];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check HTTP status
|
||||||
|
if ($httpCode !== 200) {
|
||||||
|
log_message('error', "SSO: HTTP error - Code: $httpCode, Response: $apiResponse");
|
||||||
|
return ['status' => 'failed','message' => "HTTP error: $httpCode" , "response" => $apiResponse ];
|
||||||
|
}
|
||||||
|
|
||||||
|
$jsonResponse = json_decode($apiResponse, true);
|
||||||
|
|
||||||
|
// Check JSON decode error
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
log_message('error', "SSO: JSON decode error - " . json_last_error_msg());
|
||||||
|
return ['status' => 'failed','message' => "JSON decode error: " . json_last_error_msg(), "response" => $apiResponse];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check API response status
|
||||||
|
if (!isset($jsonResponse["status"]) || $jsonResponse["status"] !== "success") {
|
||||||
|
log_message('error', "SSO: API error - " . json_encode($jsonResponse));
|
||||||
|
return ['status' => 'failed','message' => "API error", "response" => $jsonResponse];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($jsonResponse["data"])) {
|
||||||
|
log_message('error', "SSO: Missing data field in response");
|
||||||
|
return ['status' => 'failed','message' => "Invalid API response - missing data field", "response" => $jsonResponse];
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message('info', "SSO: API response validated successfully");
|
||||||
|
|
||||||
|
// ---------- STEP 4: Decrypt response ----------
|
||||||
|
log_message('info', "SSO: Starting response decryption");
|
||||||
|
|
||||||
|
$dataParts = explode(":", $jsonResponse["data"]);
|
||||||
|
|
||||||
|
if (count($dataParts) !== 2) {
|
||||||
|
log_message('error', "SSO: Invalid encrypted data format");
|
||||||
|
return ['status' => 'failed','message' => "Invalid encrypted data format", "data" => $jsonResponse["data"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
list($ivBase64, $cipherBase64) = $dataParts;
|
||||||
|
|
||||||
|
$respIv = base64_decode($ivBase64);
|
||||||
|
$respCipher = base64_decode($cipherBase64);
|
||||||
|
|
||||||
|
if ($respIv === false || $respCipher === false) {
|
||||||
|
log_message('error', "SSO: Base64 decode error");
|
||||||
|
return ['status' => 'failed','message' => "Base64 decode error"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$decryptedJson = openssl_decrypt($respCipher, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $respIv);
|
||||||
|
|
||||||
|
if ($decryptedJson === false) {
|
||||||
|
log_message('error', "SSO: Decryption failed");
|
||||||
|
return ['status' => 'failed','message' => "Decryption failed"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$decryptedData = json_decode($decryptedJson, true);
|
||||||
|
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
log_message('error', "SSO: Decrypted JSON decode error - " . json_last_error_msg());
|
||||||
|
return ['status' => 'failed','message' => "Decrypted JSON decode error: " . json_last_error_msg()];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($decryptedData["redirectUrl"])) {
|
||||||
|
log_message('error', "SSO: redirectUrl missing in decrypted data");
|
||||||
|
return ['status' => 'failed','message' => "redirectUrl missing", "decrypted" => $decryptedData];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- FINAL ----------
|
||||||
|
log_message('info', "SSO: Authentication successful, redirectUrl obtained");
|
||||||
|
return ['status' => 'success','data' => $decryptedData["redirectUrl"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------yet to start only submit claim given
|
||||||
|
|
||||||
public function fileUpload()
|
public function fileUpload()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -51,15 +51,15 @@ table.dataTable thead th {
|
|||||||
<?php foreach($addImageList as $row){ ?>
|
<?php foreach($addImageList as $row){ ?>
|
||||||
<tr >
|
<tr >
|
||||||
<td class="client_info" data-id="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></td>
|
<td class="client_info" data-id="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></td>
|
||||||
<td class="client_info" ><?php echo $row['client_name']; ?></td>
|
<td class="client_info" ><?php echo $row['client_id'] != 0 ? $row['client_name'] : '-' ; ?></td>
|
||||||
<td class="client_info" ><?php echo $row['short_name']; ?></td>
|
<td class="client_info" ><?php echo $row['client_id'] != 0 ? $row['short_name'] : '-'; ?></td>
|
||||||
<td class="client_info" ><?php echo $row['status']; ?></td>
|
<td class="client_info" ><?php echo $row['status']; ?></td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group dropdown">
|
<div class="btn-group dropdown">
|
||||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
<a class="dropdown-item advertise_image_edit" href="#" data-toggle="modal" data-wholearray='<?php echo json_encode($row, JSON_HEX_APOS); ?>' data-target="#bike_make_login-modal"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
<a class="dropdown-item advertise_image_edit" href="#" data-toggle="modal" data-wholearray='<?php echo json_encode($row, JSON_HEX_APOS); ?>' data-target="#bike_make_login-modal"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||||
<a class="dropdown-item" onclick="remove_advertise_image('<?= $row['id'];?>')"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
<?php if($row['client_id'] != 0) { ?> <a class="dropdown-item" onclick="remove_advertise_image('<?= $row['id'];?>')"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a> <?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@ -136,6 +136,7 @@ table.dataTable thead th {
|
|||||||
<label for="client_branch">Client <span class="text-danger">*</span></label>
|
<label for="client_branch">Client <span class="text-danger">*</span></label>
|
||||||
<select class="form-control" id="client_id" name="client_id" required>
|
<select class="form-control" id="client_id" name="client_id" required>
|
||||||
<option value="">Select Client</option>
|
<option value="">Select Client</option>
|
||||||
|
<option value="0">Default Image</option>
|
||||||
<?php
|
<?php
|
||||||
if (isset($client) && count($client)) {
|
if (isset($client) && count($client)) {
|
||||||
foreach ($client as $value) {
|
foreach ($client as $value) {
|
||||||
@ -209,7 +210,7 @@ table.dataTable thead th {
|
|||||||
if (response.status) {
|
if (response.status) {
|
||||||
$('#bike_make_login-modal').modal('hide');
|
$('#bike_make_login-modal').modal('hide');
|
||||||
$('#advertise_image').val('');
|
$('#advertise_image').val('');
|
||||||
$('#client_id').val('');
|
$('#client_id').val(null).trigger('change');
|
||||||
$('#uploadPreview').attr('src', '<?= base_url('public/assets/images/avatar_2x.png') ?>');
|
$('#uploadPreview').attr('src', '<?= base_url('public/assets/images/avatar_2x.png') ?>');
|
||||||
toastr.success('Image uploaded successfully!');
|
toastr.success('Image uploaded successfully!');
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@ -292,8 +293,9 @@ table.dataTable thead th {
|
|||||||
var table;
|
var table;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$('#client_id').select2();
|
||||||
$('#add_image_id').val('');
|
$('#add_image_id').val('');
|
||||||
$('#client_id').val('');
|
$('#client_id').val(null).trigger('change');
|
||||||
$('#advertise_image').val('');
|
$('#advertise_image').val('');
|
||||||
table = $('#tickets-table').DataTable({
|
table = $('#tickets-table').DataTable({
|
||||||
// dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, button right
|
// dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, button right
|
||||||
@ -332,6 +334,7 @@ table.dataTable thead th {
|
|||||||
// ✅ Define your modal function separately
|
// ✅ Define your modal function separately
|
||||||
function callmodal() {
|
function callmodal() {
|
||||||
$('#add_image_id').val(0);
|
$('#add_image_id').val(0);
|
||||||
|
$('#client_id').val(null).trigger('change');
|
||||||
$('#advertise_add_edit').html('Add Advertise Image');
|
$('#advertise_add_edit').html('Add Advertise Image');
|
||||||
$('#uploadPreview').attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
|
$('#uploadPreview').attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
|
||||||
$('#bike_model_login-modal').modal('show'); // ✅ this shows the modal
|
$('#bike_model_login-modal').modal('show'); // ✅ this shows the modal
|
||||||
@ -393,7 +396,7 @@ table.dataTable thead th {
|
|||||||
|
|
||||||
// 1. Clear fields first for a clean state (Good practice)
|
// 1. Clear fields first for a clean state (Good practice)
|
||||||
$('#add_image_id').val('');
|
$('#add_image_id').val('');
|
||||||
$('#client_id').val('');
|
$('#client_id').val(null).trigger('change');
|
||||||
$('#advertise_image').val('');
|
$('#advertise_image').val('');
|
||||||
// Reset preview to default before processing to avoid flicker/old image
|
// Reset preview to default before processing to avoid flicker/old image
|
||||||
$('#uploadPreview').attr('src', '<?= base_url("public/assets/images/avatar_2x.png") ?>');
|
$('#uploadPreview').attr('src', '<?= base_url("public/assets/images/avatar_2x.png") ?>');
|
||||||
@ -403,8 +406,8 @@ table.dataTable thead th {
|
|||||||
let ad_id = wholearray.id;
|
let ad_id = wholearray.id;
|
||||||
let c_id = wholearray.client_id; // This holds the Client ID for the dropdown
|
let c_id = wholearray.client_id; // This holds the Client ID for the dropdown
|
||||||
|
|
||||||
console.log('Whole array:', wholearray);
|
// console.log('Whole array:', wholearray);
|
||||||
console.log('Clicked ID:', c_id);
|
// console.log('Clicked ID:', ad_id);
|
||||||
|
|
||||||
// 2. Set the data fields and title
|
// 2. Set the data fields and title
|
||||||
$('#add_image_id').val(ad_id);
|
$('#add_image_id').val(ad_id);
|
||||||
@ -412,14 +415,13 @@ table.dataTable thead th {
|
|||||||
|
|
||||||
// 🎯 CRITICAL FIX: Set the value of the Client SELECT dropdown
|
// 🎯 CRITICAL FIX: Set the value of the Client SELECT dropdown
|
||||||
// This pre-selects the client associated with the image.
|
// This pre-selects the client associated with the image.
|
||||||
$('#client_id').val(c_id);
|
$('#client_id').val(c_id).trigger('change');
|
||||||
|
|
||||||
|
|
||||||
// 3. Construct the image URL
|
// 3. Construct the image URL
|
||||||
// NOTE: If this path fails (404/403), revert to the previous controller path:
|
// NOTE: If this path fails (404/403), revert to the previous controller path:
|
||||||
const imgUrl = '<?= base_url("showAdvertiseImage/"); ?>' + ad_name;
|
const imgUrl = '<?= base_url("showAdvertiseImage/"); ?>' + ad_name;
|
||||||
// const imgUrl = '<?= base_url("writable/uploads/advertiseImage/"); ?>' + ad_name;
|
// const imgUrl = '<?= base_url('public/uploads/add_image_upload/'); ?>' + ad_name;
|
||||||
|
|
||||||
|
|
||||||
// 4. Set the image source AND add robust error handling for default image
|
// 4. Set the image source AND add robust error handling for default image
|
||||||
$('#uploadPreview').attr('src', imgUrl).on('error', function() {
|
$('#uploadPreview').attr('src', imgUrl).on('error', function() {
|
||||||
|
|||||||
303
app/Views/logs/index.php
Normal file
303
app/Views/logs/index.php
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title><?= esc($title) ?></title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* body {
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 20px;
|
||||||
|
} */
|
||||||
|
|
||||||
|
.container {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 30px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header p {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert {
|
||||||
|
padding: 15px 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-success {
|
||||||
|
background: #d4edda;
|
||||||
|
color: #155724;
|
||||||
|
border: 1px solid #c3e6cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-error {
|
||||||
|
background: #f8d7da;
|
||||||
|
color: #721c24;
|
||||||
|
border: 1px solid #f5c6cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
border-bottom: 2px solid #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-danger {
|
||||||
|
background: #dc3545;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-danger:hover {
|
||||||
|
background: #c82333;
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background: #667eea;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background: #5568d3;
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-success {
|
||||||
|
background: #28a745;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-success:hover {
|
||||||
|
background: #218838;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sm {
|
||||||
|
padding: 6px 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead {
|
||||||
|
background: #f8f9fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
padding: 15px;
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #495057;
|
||||||
|
border-bottom: 2px solid #dee2e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
padding: 15px;
|
||||||
|
border-bottom: 1px solid #dee2e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody tr {
|
||||||
|
transition: background 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody tr:hover {
|
||||||
|
background: #f8f9fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-logs {
|
||||||
|
text-align: center;
|
||||||
|
padding: 60px 20px;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-logs svg {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-name {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #667eea;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
flex: 1;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card h3 {
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card p {
|
||||||
|
opacity: 0.9;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<!-- <div class="header">
|
||||||
|
<h1>📋 Log File Manager</h1>
|
||||||
|
<p>View and manage your CodeIgniter 4 log files</p>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<?php if (session()->getFlashdata('success')): ?>
|
||||||
|
<div class="alert alert-success">
|
||||||
|
✓ <?= session()->getFlashdata('success') ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if (session()->getFlashdata('error')): ?>
|
||||||
|
<div class="alert alert-error">
|
||||||
|
✗ <?= session()->getFlashdata('error') ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<!-- <div class="stats">
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3><?= count($logFiles) ?></h3>
|
||||||
|
<p>Total Log Files</p>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<div class="actions">
|
||||||
|
<h2 style="color: #495057;">Log Files</h2>
|
||||||
|
<?php if (!empty($logFiles)): ?>
|
||||||
|
<!-- <a href="<?= base_url('logs/clearAll') ?>"
|
||||||
|
class="btn btn-danger"
|
||||||
|
onclick="return confirm('Are you sure you want to delete all log files?')">
|
||||||
|
🗑️ Clear All Logs
|
||||||
|
</a> -->
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (empty($logFiles)): ?>
|
||||||
|
<div class="no-logs">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
||||||
|
</svg>
|
||||||
|
<h3>No Log Files Found</h3>
|
||||||
|
<p>There are no log files to display at the moment.</p>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="table-wrapper">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>File Name</th>
|
||||||
|
<th>Size</th>
|
||||||
|
<th>Last Modified</th>
|
||||||
|
<th style="text-align: center;">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($logFiles as $file): ?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span class="file-name">
|
||||||
|
📄 <?= esc($file['name']) ?>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td><?= esc($file['size']) ?></td>
|
||||||
|
<td><?= esc($file['modified_date']) ?></td>
|
||||||
|
<td>
|
||||||
|
<div class="action-buttons" style="justify-content: center;">
|
||||||
|
<a href="<?= base_url('logs/view/' . urlencode($file['name'])) ?>"
|
||||||
|
class="btn btn-primary btn-sm">
|
||||||
|
View
|
||||||
|
</a>
|
||||||
|
<a href="<?= base_url('logs/download/' . urlencode($file['name'])) ?>"
|
||||||
|
class="btn btn-success btn-sm">
|
||||||
|
Download
|
||||||
|
</a>
|
||||||
|
<!-- <a href="<?= base_url('logs/delete/' . urlencode($file['name'])) ?>"
|
||||||
|
class="btn btn-danger btn-sm"
|
||||||
|
onclick="return confirm('Are you sure you want to delete this log file?')">
|
||||||
|
Delete
|
||||||
|
</a> -->
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
483
app/Views/logs/view.php
Normal file
483
app/Views/logs/view.php
Normal file
@ -0,0 +1,483 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title><?= esc($title) ?></title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* body {
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 20px;
|
||||||
|
} */
|
||||||
|
|
||||||
|
.container {
|
||||||
|
max-width: 1400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
/* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
|
||||||
|
color: black;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
font-size: 1.8rem;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.file-info {
|
||||||
|
display: flex;
|
||||||
|
gap: 30px;
|
||||||
|
margin-top: 15px;
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-info-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 15px;
|
||||||
|
background: #f8f9fa;
|
||||||
|
border-radius: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-group {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-btn {
|
||||||
|
padding: 8px 16px;
|
||||||
|
border: 2px solid #dee2e6;
|
||||||
|
background: white;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-btn:hover {
|
||||||
|
border-color: #667eea;
|
||||||
|
color: #667eea;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-btn.active {
|
||||||
|
background: #667eea;
|
||||||
|
color: white;
|
||||||
|
border-color: #667eea;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
padding: 10px 15px;
|
||||||
|
border: 2px solid #dee2e6;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
width: 300px;
|
||||||
|
transition: border-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #667eea;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entries {
|
||||||
|
background: #f8f9fa;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
max-height: 600px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry {
|
||||||
|
background: white;
|
||||||
|
border-left: 4px solid #6c757d;
|
||||||
|
padding: 15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry:hover {
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
transform: translateX(5px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry.critical {
|
||||||
|
border-left-color: #dc3545;
|
||||||
|
background: #fff5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry.error {
|
||||||
|
border-left-color: #fd7e14;
|
||||||
|
background: #fff8f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry.warning {
|
||||||
|
border-left-color: #ffc107;
|
||||||
|
background: #fffef5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry.info {
|
||||||
|
border-left-color: #17a2b8;
|
||||||
|
background: #f5fcfd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry.debug {
|
||||||
|
border-left-color: #6c757d;
|
||||||
|
background: #f8f9fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-level {
|
||||||
|
padding: 4px 12px;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.level-critical {
|
||||||
|
background: #dc3545;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.level-error {
|
||||||
|
background: #fd7e14;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.level-warning {
|
||||||
|
background: #ffc107;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.level-info {
|
||||||
|
background: #17a2b8;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.level-debug {
|
||||||
|
background: #6c757d;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-date {
|
||||||
|
color: #6c757d;
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-message {
|
||||||
|
color: #333;
|
||||||
|
line-height: 1.6;
|
||||||
|
font-size: 14px;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-wrap: break-word;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-logs {
|
||||||
|
text-align: center;
|
||||||
|
padding: 60px 20px;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||||
|
gap: 15px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
background-color: #fff;
|
||||||
|
color: #333;
|
||||||
|
padding: 0px;
|
||||||
|
border: 1px solid #007bff;
|
||||||
|
border-radius: 5px;
|
||||||
|
text-align: center;
|
||||||
|
border-width: 1px;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.stat-card:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
|
||||||
|
border-color: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card h3 {
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card p {
|
||||||
|
opacity: 0.9;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.search-box {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-group {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||||
|
<h1>
|
||||||
|
📄 <?= esc($filename) ?>
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<div style="display:flex; gap:10px; margin-bottom:15px;">
|
||||||
|
<?php if ($prevFile): ?>
|
||||||
|
<a href="<?= base_url('logs/view/' . $prevFile) ?>" class="btn btn-primary">Previous</a>
|
||||||
|
<?php else: ?>
|
||||||
|
<button class="btn btn-secondary" disabled>⬅ Previous Day</button>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($nextFile): ?>
|
||||||
|
<a href="<?= base_url('logs/view/' . $nextFile) ?>" class="btn btn-primary">Next</a>
|
||||||
|
<?php else: ?>
|
||||||
|
<button class="btn btn-secondary" disabled>Next Day ➡</button>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <div class="file-info">
|
||||||
|
<div class="file-info-item">
|
||||||
|
<strong>Size:</strong> <?= esc($fileSize) ?>
|
||||||
|
</div>
|
||||||
|
<div class="file-info-item">
|
||||||
|
<strong>Last Modified:</strong> <?= esc($lastModified) ?>
|
||||||
|
</div>
|
||||||
|
<div class="file-info-item">
|
||||||
|
<strong>Total Entries:</strong> <?= count($logEntries) ?>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<div class="stats">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--<div class="stat-card">
|
||||||
|
<h3 id="total-count"><?= count($logEntries) ?></h3>
|
||||||
|
<p>Total Entries</p>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="critical-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => strtoupper($e['level']) === 'CRITICAL')) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Critical</p>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="error-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => strtoupper($e['level']) === 'ERROR')) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Errors</p>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="warning-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => strtoupper($e['level']) === 'WARNING')) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Warnings</p>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="newtoken-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => stripos($e['message'], 'TPA CLAIM PUSH SUCCESS') !== false)) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Claim success</p>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="newtoken-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => stripos($e['message'], 'TPA CLAIM PUSH FAILED') !== false)) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Claim failed</p>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="newtoken-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => stripos($e['message'], 'TPA ID PULL SUCCESS') !== false)) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Tpa no pull success</p>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="newtoken-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => stripos($e['message'], 'TPA ID PULL FAILED') !== false)) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Tpa no pull Failed</p>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="newtoken-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => stripos($e['message'], 'CLAIM STATUS SUCCESS') !== false)) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Claim status fetch success</p>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="newtoken-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => stripos($e['message'], 'CLAIM STATUS FAILED') !== false)) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Claim status fetch failed</p>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<h3 id="newtoken-count">
|
||||||
|
<?= count(array_filter($logEntries, fn($e) => stripos($e['message'], 'Ecard Request PUSH SUCCESS') !== false)) ?>
|
||||||
|
</h3>
|
||||||
|
<p>Ecard Request</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="controls">
|
||||||
|
<div class="filter-group">
|
||||||
|
<strong>Filter:</strong>
|
||||||
|
<button class="filter-btn active" data-level="all">All</button>
|
||||||
|
<button class="filter-btn" data-level="critical">Critical</button>
|
||||||
|
<button class="filter-btn" data-level="error">Error</button>
|
||||||
|
<button class="filter-btn" data-level="warning">Warning</button>
|
||||||
|
<button class="filter-btn" data-level="info">Info</button>
|
||||||
|
<button class="filter-btn" data-level="debug">Debug</button>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="search-box" id="searchBox" placeholder="🔍 Search log messages...">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (empty($logEntries)): ?>
|
||||||
|
<div class="no-logs">
|
||||||
|
<h3>No Log Entries Found</h3>
|
||||||
|
<p>This log file is empty or couldn't be parsed.</p>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="log-entries" id="logEntries">
|
||||||
|
<?php foreach ($logEntries as $entry): ?>
|
||||||
|
<?php
|
||||||
|
$level = strtolower($entry['level']);
|
||||||
|
$levelClass = 'level-' . $level;
|
||||||
|
?>
|
||||||
|
<div class="log-entry <?= $level ?>" data-level="<?= $level ?>">
|
||||||
|
<div class="log-header">
|
||||||
|
<span class="log-level <?= $levelClass ?>">
|
||||||
|
<?= esc(strtoupper($entry['level'])) ?>
|
||||||
|
</span>
|
||||||
|
<span class="log-date"><?= esc($entry['date']) ?></span>
|
||||||
|
</div>
|
||||||
|
<div class="log-message"><?= esc($entry['message']) ?></div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Filter functionality
|
||||||
|
const filterBtns = document.querySelectorAll('.filter-btn');
|
||||||
|
const logEntries = document.querySelectorAll('.log-entry');
|
||||||
|
const searchBox = document.getElementById('searchBox');
|
||||||
|
|
||||||
|
let currentFilter = 'all';
|
||||||
|
|
||||||
|
filterBtns.forEach(btn => {
|
||||||
|
btn.addEventListener('click', () => {
|
||||||
|
filterBtns.forEach(b => b.classList.remove('active'));
|
||||||
|
btn.classList.add('active');
|
||||||
|
currentFilter = btn.dataset.level;
|
||||||
|
applyFilters();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
searchBox.addEventListener('input', applyFilters);
|
||||||
|
|
||||||
|
function applyFilters() {
|
||||||
|
const searchTerm = searchBox.value.toLowerCase();
|
||||||
|
|
||||||
|
logEntries.forEach(entry => {
|
||||||
|
const level = entry.dataset.level;
|
||||||
|
const message = entry.querySelector('.log-message').textContent.toLowerCase();
|
||||||
|
|
||||||
|
const matchesFilter = currentFilter === 'all' || level === currentFilter;
|
||||||
|
const matchesSearch = message.includes(searchTerm);
|
||||||
|
|
||||||
|
if (matchesFilter && matchesSearch) {
|
||||||
|
entry.classList.remove('hidden');
|
||||||
|
} else {
|
||||||
|
entry.classList.add('hidden');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user