From c64d32876a5745ae91ba88c836ca2eece6e89b24 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Fri, 8 May 2026 16:04:46 +0530 Subject: [PATCH 1/2] GWM : merger claim files to be pushed to TAP --- app/Controllers/EmployeeRestController.php | 26 ++++++++++++-------- app/Controllers/FhplApiController.php | 2 +- app/Controllers/HealthIndiaApiController.php | 2 +- app/Controllers/MediAssistApiController.php | 2 +- app/Controllers/TicketController.php | 21 +++++++--------- app/Controllers/VidalApiController.php | 2 +- app/Controllers/VoloApiController.php | 2 +- app/Views/claim_files_upload.php | 12 ++++++--- 8 files changed, 39 insertions(+), 30 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 193762d9..9518d202 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3785,6 +3785,14 @@ class EmployeeRestController extends AdminController $this->handleCliamFiles($file_data, $ticket_id, $ticket_message_id); + // Merge all uploaded PDFs for this ticket into a single combined PDF + try { + helper('merge_pdf'); + merge_ticket_pdfs((int) $ticket_id); + } catch (\Throwable $e) { + log_message('error', 'EmployeeRestController::initiateClaim | merge_ticket_pdfs failed | ticket_id=' . $ticket_id . ' | ' . $e->getMessage()); + } + $mail_sent_status = ($this->ticketController->sendAutoMailTrigger($ticket_id)); if (gettype($mail_sent_status) == 'array') { $message = 'Claim Iniated Successfully'; @@ -3923,16 +3931,6 @@ class EmployeeRestController extends AdminController } } - // Merge all uploaded PDFs for this ticket into a single combined PDF - if ($pdf_exist_in_the_file) { - try { - helper('merge_pdf'); - merge_ticket_pdfs((int) $ticket_id); - } catch (\Throwable $e) { - log_message('error', 'EmployeeRestController::handleCliamFiles | merge_ticket_pdfs failed | ticket_id=' . $ticket_id . ' | ' . $e->getMessage()); - } - } - $count = $this->ticketMaster->where('id', $ticket_id)->where('is_active', 1)->where('tpa_claim_push_reference_no IS NULL')->countAllResults(); log_message('error', 'Ticket validation | Ticket ID: ' . $ticket_id . ' | Matching active tickets with NULL TPA reference: ' . $count); if ($count > 0 && $pdf_exist_in_the_file && $tpa_claim_push == true) { @@ -5454,6 +5452,14 @@ class EmployeeRestController extends AdminController $result = $this->handleCliamFiles($file_data, $ticket_id, null, false, true); if (! empty($result)) { + // Merge all uploaded PDFs for this ticket into a single combined PDF + try { + helper('merge_pdf'); + merge_ticket_pdfs((int) $ticket_id); + } catch (\Throwable $e) { + log_message('error', 'EmployeeRestController::uploadIRDocs | merge_ticket_pdfs failed | ticket_id=' . $ticket_id . ' | ' . $e->getMessage()); + } + // $this->ticketMaster->where('id', $ticket_id)->set(['required_docs', $required_docs])->update(); db_connect()->query( "UPDATE ticket_master SET required_docs = ? WHERE id = ?", diff --git a/app/Controllers/FhplApiController.php b/app/Controllers/FhplApiController.php index 542f461b..dfa7db1b 100644 --- a/app/Controllers/FhplApiController.php +++ b/app/Controllers/FhplApiController.php @@ -92,7 +92,7 @@ class FhplApiController extends BaseController ->join('employees e', 'e.id = tm.emp_id', 'left') ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') ->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left') - ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 2 AND cf.mime_type='application/pdf'", 'left') + ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 4 AND cf.is_active = 1 AND cf.mime_type = 'application/pdf'", 'left') ->where('tm.id', $claimId) ->get() ->getRowArray(); diff --git a/app/Controllers/HealthIndiaApiController.php b/app/Controllers/HealthIndiaApiController.php index db356888..46b67043 100644 --- a/app/Controllers/HealthIndiaApiController.php +++ b/app/Controllers/HealthIndiaApiController.php @@ -113,7 +113,7 @@ class HealthIndiaApiController extends BaseController ->join('employees e', 'e.id = tm.emp_id', 'left') ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') ->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left') - ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 2 AND cf.mime_type='application/pdf'", 'left') + ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 4 AND cf.is_active = 1 AND cf.mime_type = 'application/pdf'", 'left') ->where('tm.id', $claimId) ->get() ->getRowArray(); diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php index 341e3f9b..cb39d93c 100644 --- a/app/Controllers/MediAssistApiController.php +++ b/app/Controllers/MediAssistApiController.php @@ -67,7 +67,7 @@ class MediAssistApiController extends BaseController ->join('employees e', 'e.id = tm.emp_id', 'left') ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') ->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left') - ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 2 and cf.mime_type = 'application/pdf'", 'left') + ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 4 AND cf.is_active = 1 AND cf.mime_type = 'application/pdf'", 'left') ->where('tm.id', $claimId) ->get() ->getRowArray(); // single record diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index bd293ae4..6f64777c 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -2066,16 +2066,6 @@ class TicketController extends BaseController $return_value = $this->ticketMasterModel->where('id', $ticket_id)->set($ticket_data)->update(); if ($return_value) { - // Merge all uploaded PDFs for this ticket into a single combined PDF - try { - helper('merge_pdf'); - merge_ticket_pdfs((int) $ticket_id, [ - 'ticket_type' => (int) ($ticket_data['ticket_type_id'] ?? 1), - ]); - } catch (\Throwable $e) { - log_message('error', 'TicketController::updateTicket | merge_ticket_pdfs failed | ticket_id=' . $ticket_id . ' | ' . $e->getMessage()); - } - $mail_responce = null; if($old_ticket_data['claim_status_id'] != $ticket_data['claim_status_id']){ //mail trigger part @@ -2413,7 +2403,7 @@ class TicketController extends BaseController $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) { + if ($file_record === null || ! in_array((int) ($file_record['file_type'] ?? 0), [2, 4], true)) { throw PageNotFoundException::forPageNotFound(); } @@ -3687,6 +3677,13 @@ class TicketController extends BaseController $employeeRest = new EmployeeRestController(); $result = $employeeRest->handleCliamFiles($file_data, $ticket_id); if(!empty($result)){ + // Merge all uploaded PDFs for this ticket into a single combined PDF + try { + helper('merge_pdf'); + merge_ticket_pdfs((int) $ticket_id); + } catch (\Throwable $e) { + log_message('error', 'TicketController::upload_url | merge_ticket_pdfs failed | ticket_id=' . $ticket_id . ' | ' . $e->getMessage()); + } return $this->respond(['status' => true, 'message' => 'File uploaded successfully ']); }else{ return $this->respond(['status' => false, 'message' => 'Failed to upload file ']); @@ -3714,7 +3711,7 @@ class TicketController extends BaseController ->select(" *, CASE - WHEN file_type = 2 AND url IS NOT NULL AND url != '' + WHEN file_type IN (2, 4) AND url IS NOT NULL AND url != '' THEN CONCAT('" . base_url('downloadClaimFile/') . "', id) ELSE url END AS url diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php index d1fd6b40..889ae745 100644 --- a/app/Controllers/VidalApiController.php +++ b/app/Controllers/VidalApiController.php @@ -168,7 +168,7 @@ class VidalApiController extends BaseController ->join('policy_type pt', 'pt.id = cp.policy_type_id', 'left') ->join('employee_polices ep', 'ep.employee_id = e.id AND ep.client_policy_id = cp.id', 'left') ->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left') - ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 2 and cf.mime_type = 'application/pdf'", 'left') + ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 4 AND cf.is_active = 1 AND cf.mime_type = 'application/pdf'", 'left') ->where('tm.id', $claimId) ->get() ->getRowArray(); // single record diff --git a/app/Controllers/VoloApiController.php b/app/Controllers/VoloApiController.php index 63e63c6d..b1bc0a4b 100644 --- a/app/Controllers/VoloApiController.php +++ b/app/Controllers/VoloApiController.php @@ -696,7 +696,7 @@ class VoloApiController extends BaseController cf.url as filePath ') ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') - ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 2 AND cf.mime_type = 'application/pdf'", 'left') + ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 4 AND cf.is_active = 1 AND cf.mime_type = 'application/pdf'", 'left') ->where('tm.id', $claimId) ->get() ->getRowArray(); diff --git a/app/Views/claim_files_upload.php b/app/Views/claim_files_upload.php index 1f1d7e39..6ea03e37 100644 --- a/app/Views/claim_files_upload.php +++ b/app/Views/claim_files_upload.php @@ -475,13 +475,19 @@ } } + function claimFileIsLocalUpload(item) { + // file_type 2 = uploaded claim doc, 4 = merged combined PDF (both stored on disk) + return item.file_type == 2 || item.file_type === '2' + || item.file_type == 4 || item.file_type === '4'; + } + function claimFileViewSupported(item) { var mime = String(item.mime_type || '').toLowerCase(); if (mime === 'application/pdf' || mime === 'image/png' || mime === 'image/jpeg') { return true; } var ext = ''; - if (item.file_type == 2 || item.file_type === '2') { + if (claimFileIsLocalUpload(item)) { ext = claimFileListExtension(item.file_name) || claimFileListExtension(item.doc_name); } else { ext = claimFileListExtensionFromUrl(item.url); @@ -493,14 +499,14 @@ } function claimFileViewOpenUrl(item, base_url) { - if (item.file_type == 2 || item.file_type === '2') { + if (claimFileIsLocalUpload(item)) { return base_url + 'viewClaimFile/' + encodeURIComponent(item.id); } return String(item.url || ''); } function claimFileDownloadOpenUrl(item, base_url) { - if (item.file_type == 2 || item.file_type === '2') { + if (claimFileIsLocalUpload(item)) { return base_url + 'downloadClaimFile/' + encodeURIComponent(item.id); } return String(item.url || ''); From 942ba8b37693360abcba6a0eeda0ee947a7ddf83 Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Fri, 8 May 2026 16:45:26 +0530 Subject: [PATCH 2/2] FIX_Dashboard --- app/Views/DashBoard.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php index 5e2b1ee1..561e8098 100755 --- a/app/Views/DashBoard.php +++ b/app/Views/DashBoard.php @@ -185,6 +185,27 @@ + +