From 71acec9060687305c56f0ed58995e0af13da6731 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 6 Jan 2026 10:52:13 +0530 Subject: [PATCH] FIX_ISSUE --- app/Controllers/TicketController.php | 37 ++++++++++++++++++++++++++++ app/Views/ticket_form_handler.php | 8 ++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 07b8db0e..51775eec 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -1124,6 +1124,43 @@ class TicketController extends BaseController // $ticket_data = $this->getLastMatchedStatus($ticket_data, ); // print_rr($ticket_data); die; + $isduplicate = checkDuplicateClaim([ + 'doa' => change_date_format($ticket_data['doa'] ?? '') ?? null, + 'emp_code' => $ticket_data['emp_code'] ?? null, + 'claim_amount' => $ticket_data['claim_amount'] ?? null, + 'policy_no' => $ticket_data['policy_no'] ?? null + ]); + + if ($isduplicate) { + + $errorDetails = []; + + if (!empty($ticket_data['doa'])) { + $errorDetails[] = 'DOA: ' . change_date_format($ticket_data['doa']); + } + + if (!empty($ticket_data['claim_amount'])) { + $errorDetails[] = 'Claim Amount: ₹' . number_format($ticket_data['claim_amount'], 2); + } + + if (!empty($ticket_data['emp_code'])) { + $errorDetails[] = 'Emp Code: ' . $ticket_data['emp_code']; + } + + if (!empty($ticket_data['policy_no'])) { + $errorDetails[] = 'Policy No: ' . $ticket_data['policy_no']; + } + + $response = [ + 'status' => false, + 'code' => 409, + 'message' => 'Duplicate claim found for ' . implode(', ', $errorDetails) + ]; + + return $this->respond($response, 200); + } + + if ($ticket_data) { $return_value = $this->ticketMasterModel->insert($ticket_data); if ($return_value) { diff --git a/app/Views/ticket_form_handler.php b/app/Views/ticket_form_handler.php index 07637cf6..17a6715e 100644 --- a/app/Views/ticket_form_handler.php +++ b/app/Views/ticket_form_handler.php @@ -770,11 +770,15 @@ if (response.status === true) { toastr.success(response.message, 'SUCCESS'); + window.location.href = ''; } else { - toastr.error(response.message, 'ERROR'); + if(response.code == 409){ + toastr.warning(response.message, 'WARNING'); + }else{ + toastr.error(response.message, 'ERROR'); + } } - window.location.href = ''; }, error: function(xhr, status, error) { console.error(xhr.responseText);