From 20329dfa20a9d4a68692dab7a62db8971b270821 Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Wed, 13 May 2026 13:00:24 +0530 Subject: [PATCH] FIX_DOWNLOAD_ISSUE --- .../PolicyTransactionController.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 0f15f31d..b0a7cb12 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -5065,6 +5065,27 @@ class PolicyTransactionController extends BaseController } } + public function downloadInsurerStatement($id) + { + $statement = $this->insurerStatements + ->where('id', (int) $id) + ->where('is_active', 1) + ->first(); + + if (empty($statement) || empty($statement['file_name'])) { + throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound('Statement file not found'); + } + + $fileName = basename($statement['file_name']); + $filePath = WRITEPATH . 'uploads/statements/' . $fileName; + + if (!is_file($filePath)) { + throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound('Statement file not found'); + } + + return $this->response->download($filePath, null)->setFileName($fileName); + } + public function getFileErr() { $file_id = $this->request->getUri()->getSegment(4);