diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 251e26ee..0129af3d 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -87,6 +87,7 @@ $routes->get('download-e-card/(:any)', 'EmployeeController::generateIDCardForEmp $routes->get('download-kyc-docs/(:segment)', 'ClientController::downloadKYCDocument/$1'); $routes->get('claim-form-download/(:any)', 'TicketController::downloadClaimForm/$1'); $routes->get('downloadClaimFile/(:any)', 'TicketController::downloadClaimFile/$1'); +$routes->get('viewClaimFile/(:any)', 'TicketController::viewClaimFile/$1'); $routes->match (['get','post'],"claims-feedback-form/(:any)/(:any)", "TicketController::viewClaimFeedbackForm/$1/$2"); $routes->match (['get','post'],"claims-feedback-form/(:any)", "TicketController::viewClaimFeedbackForm/$1"); $routes->get('downloadEmployeeEcardZip/(:any)', 'EmployeeController::downloadEmployeeEcardZip/$1'); @@ -812,6 +813,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->get("getMoreInfo","TicketController::getMoreInfo"); $routes->post('upload_url',"TicketController::upload_url"); $routes->post('getUrlDataByTicketId',"TicketController::getUrlDataByTicketId"); + $routes->post('uploadClaimFilesToTPA', 'TicketController::uploadClaimFilesToTPA'); $routes->get('remove_url',"TicketController::remove_url"); $routes->get('fetchVehiclePolicy/(:any)','TicketController::fetchVehiclePolicy/$1'); $routes->post('saveIRDocsJson',"TicketController::saveIRDocsJson"); diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php index 536015d0..341e3f9b 100644 --- a/app/Controllers/MediAssistApiController.php +++ b/app/Controllers/MediAssistApiController.php @@ -908,7 +908,7 @@ class MediAssistApiController extends BaseController return [ 'status' => false, - 'message' => "ClaimID not found for ticket {$claimId}" + 'message' => "Claim Number not found for Claim {$claimId}" ]; } diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index b3607027..d7f3129a 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -33,6 +33,8 @@ use Kint\Kint; use App\Helpers\MailHelper; +use CodeIgniter\Exceptions\PageNotFoundException; + class TicketController extends BaseController { use ResponseTrait; @@ -628,7 +630,14 @@ class TicketController extends BaseController $startDate = date('Y-m-d 00:00:00', strtotime($search_data['start_date'])); $endDate = date('Y-m-d 23:59:59', strtotime($search_data['end_date'])); $rawWhere[] = "tm.updated_at BETWEEN '$startDate' AND '$endDate'"; - }elseif($search_objects != "date_type" && $search_objects != "start_date" && $search_objects != "end_date"){ + } elseif ($search_objects === 'tpa_claim_type') { + $cat = strtolower(trim((string) $key)); + if ($cat === 'cashless') { + $rawWhere[] = "LOWER(COALESCE(tm.tpa_claim_type, '')) LIKE '%cash%'"; + } elseif ($cat === 'reimbursement') { + $rawWhere[] = "LOWER(COALESCE(tm.tpa_claim_type, '')) LIKE '%reimburse%'"; + } + } elseif($search_objects != "date_type" && $search_objects != "start_date" && $search_objects != "end_date"){ $where[$search_objects] = $key; } } @@ -2382,6 +2391,39 @@ class TicketController extends BaseController } } + /** + * Inline preview in browser for uploaded claim files (PDF / PNG / JPG / JPEG only). + */ + public function viewClaimFile($claim_file_id = null) + { + if ($claim_file_id === null || $claim_file_id === '') { + throw PageNotFoundException::forPageNotFound(); + } + + $claimFiles = new ClaimFilesModel(); + $file_record = $claimFiles->where('id', $claim_file_id)->where('is_active', 1)->first(); + + if ($file_record === null || (int) ($file_record['file_type'] ?? 0) !== 2) { + throw PageNotFoundException::forPageNotFound(); + } + + $url = $file_record['url']; + $parts = explode('/', $url); + $fileName = end($parts); + $filePath = WRITEPATH . '/uploads/claim_files/' . $fileName; + + if (! is_file($filePath)) { + throw PageNotFoundException::forPageNotFound(); + } + + $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION) ?: ''); + if (! in_array($ext, ['pdf', 'png', 'jpg', 'jpeg'], true)) { + throw PageNotFoundException::forPageNotFound(); + } + + return $this->response->download($filePath, null, true)->inline()->setFileName($fileName); + } + public function convertHtmlToTextOld($html) { if(!empty($html)){ @@ -3950,7 +3992,9 @@ class TicketController extends BaseController return $this->respond(['status' => false, 'message' => 'Ticket not found'], 404); } - if (!empty($ticket_data['approved_letter'])) { + $claimStatusId = (int) ($ticket_data['claim_status_id'] ?? 0); + $approvedLetterReplaceStatuses = [10, 11]; + if (!empty($ticket_data['approved_letter']) && !in_array($claimStatusId, $approvedLetterReplaceStatuses, true)) { return $this->respond([ 'status' => false, 'message' => 'Approved letter already available', @@ -4008,6 +4052,29 @@ class TicketController extends BaseController } } + public function uploadClaimFilesToTPA() + { + try { + $ticket_id = $this->request->getPost('ticket_id'); + + if (empty($ticket_id)) { + return $this->respond(['status' => false, 'message' => 'Ticket ID and Status ID are required'], 400); + } + + $apiServiceController = new ApiServiceController(); + $response = $apiServiceController->pushClaimFiles($ticket_id); + if ($response['status'] ?? false) { + return $this->respond(['status' => true, 'message' => 'Claim files uploaded to TPA successfully'], 200); + } else { + return $this->respond(['status' => false, 'message' => $response['message'] ?? 'Failed to upload claim files to TPA'], 200); + } + + } catch (\Exception $e) { + $this->myLogger->logme('error', 'Error in uploadClaimFilesToTPA: ' . $e->getMessage() . ' in file ' . $e->getFile() . ' on line ' . $e->getLine() . $e->getTraceAsString()); + return $this->respond(['status' => false, 'message' => 'An error occurred while uploading claim files to TPA'], 500); + } + } + // -------- CLAIM DUMP UPLOAD ---------------------------------------------------------------------------------------------- public function claimDumpUpload() diff --git a/app/Views/claim_files_upload.php b/app/Views/claim_files_upload.php index 4a8380b7..e8f4429e 100644 --- a/app/Views/claim_files_upload.php +++ b/app/Views/claim_files_upload.php @@ -98,11 +98,16 @@