From 1b043721f97be82dde54d632681c141ee9792ff6 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 9 Sep 2025 19:06:16 +0530 Subject: [PATCH] FIX_ISSUE --- app/Controllers/EmployeeRestController.php | 46 ++++++++++++---------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 5bd6097b..5324a61e 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3732,6 +3732,7 @@ class EmployeeRestController extends AdminController ]; foreach ($ticket_data as $key => $value) { + foreach ($client_claim_status as $claim_key => $claim_value) { if (in_array($value['claim_status_id'], $claim_value)) { // Corrected argument order $ticket_data[$key]['claim_status'] = $claim_key ?? null; // Assign back to the main array @@ -3748,30 +3749,35 @@ class EmployeeRestController extends AdminController $ticket_data[$key]['ticket_policy_type'] = $ticketTypeArray[$value['ticket_type_id']] ?? null; $ticketMesssageModel = new TicketMessageModel(); - $ticket_message_id = $ticketMesssageModel - ->where('is_active', 1) - ->where('sender', "user") - ->where('ticket_id', $ticket_id) - ->orderBy('id', "desc") - ->first(); + $ticket_message = $ticketMesssageModel + ->where('is_active', 1) + ->where('sender', "user") + ->where('ticket_id', $ticket_id) + ->orderBy('id', "desc") + ->first(); - $claimFiles = new ClaimFilesModel(); - $claim_files_data = $claimFiles - ->select('id as claim_file_id, doc_name as claim_file_name') - ->where('is_active', 1) - ->where('file_type', 2) - ->where('ticket_id', $ticket_id) - ->where('ticket_message_id', $ticket_message_id['id']) - ->findAll(); + $claim_file_urls = []; - $claim_file_urls = []; - foreach ($claim_files_data as $key => &$value) { - $value['url'] = base_url('downloadClaimFile/') . $value['id']; - $claim_file_urls[] = $value; + if ($ticket_message && isset($ticket_message['id'])) { + $claimFiles = new ClaimFilesModel(); + $claim_files_data = $claimFiles + ->select('id as claim_file_id, doc_name as claim_file_name') + ->where('is_active', 1) + ->where('file_type', 2) + ->where('ticket_id', $ticket_id) + ->where('ticket_message_id', $ticket_message['id']) + ->findAll(); + + foreach ($claim_files_data as &$value) { + $value['url'] = base_url('downloadClaimFile/') . $value['claim_file_id']; + $claim_file_urls[] = $value; + } + unset($value); } - unset($value); - $ticket_data[$key]['claim_files'] = $claim_file_urls; + // always set the key (empty if no files found) + $ticket_data['claim_files'] = $claim_file_urls; + } }