From ab420c7054ea02e68883acf4dd89a0c446cc1bdc Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 19 Nov 2025 11:01:31 +0530 Subject: [PATCH] FIX_CLAIM_STATUS --- app/Controllers/EmployeeRestController.php | 2 ++ app/Models/TicketMasterModel.php | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 733c2352..19563217 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3850,6 +3850,8 @@ class EmployeeRestController extends AdminController 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 + }else if(in_array($value['old_status_id'], $claim_value)){ + $ticket_data[$key]['claim_status'] = $claim_key ?? null; // Assign back to the main array } } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 05196827..bf40409b 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -793,7 +793,26 @@ class TicketMasterModel extends Model //api public function get_ticket_data($emp_id, $returnType,$ticket_type = null, $ticket_id = null) { - $query = $this->select('ticket_master.*, tms.mail_subject as subject, tms.id as ticket_message_id') + $query = $this->select(" + + ticket_master.*, + tms.mail_subject as subject, + tms.id as ticket_message_id, + ( + SELECT th1.old_value + FROM ticket_history th1 + JOIN ticket_claim_status tcs ON th1.old_value = tcs.id + WHERE th1.field_name = 'claim_status_id' + AND th1.ticket_id = ticket_master.id + AND th1.id = ( + SELECT MAX(th2.id) + FROM ticket_history th2 + WHERE th2.ticket_id = th1.ticket_id + AND th2.field_name = 'claim_status_id' + ) + ) AS old_status_id + + ") ->join('ticket_messages tms', 'ticket_master.id = tms.ticket_id', 'left') ->where('ticket_master.is_active', 1); $query->whereIn('sender', ['staff', 'user']);