diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 7b42c29a..69871607 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -554,6 +554,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports'); $routes->post('getPolicyStartDate','TicketController::getPolicyStartDate'); $routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID"); + $routes->post("getMoreInfo","TicketController::getMoreInfo"); // $routes->post('ticket_messages','TicketController::getTicketMessage'); }); diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index e1fe7977..1a223689 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -54,6 +54,8 @@ class TicketController extends BaseController public function __construct() { $this->myLogger = \Config\Services::mylogger(); + set_session_context('Ticket Master Controller'); + $this->ticketMasterModel = new TicketMasterModel(); @@ -1761,4 +1763,84 @@ class TicketController extends BaseController $this->loadLayout("ticket_feedback_list",$data); } + public function getMoreInfo() { + $ticket_id = $this->request->getPost('ticket_id'); + $this->myLogger->logme("error", "Ticket ID : " . $ticket_id); + + $fields = $this->extraFields; + $data_to_send = []; + + // Get ticket data + $ticket_data = $this->ticketMasterModel->where("id", $ticket_id)->where("is_active", 1)->first(); + + // Query previous status + $ticket_previous_status = $this->ticketMasterModel + ->select("th.old_value, tcs.claim_status") + ->join("ticket_history th", "th.ticket_id = ticket_master.id AND th.field_name = 'claim_status_id' AND th.is_active = 1") + ->join("ticket_claim_status tcs", "tcs.id = th.old_value AND tcs.is_active = 1") + ->where("ticket_master.is_active", 1) + ->where("ticket_master.id", $ticket_id) + ->groupBy("th.old_value, tcs.claim_status") + ->get() + ->getResultArray(); + + // Loop through previous status and gather the required data + foreach ($ticket_previous_status as $status) { + $this->myLogger->logme("error", "Status : " . json_encode($status)); + + if (isset($fields[$status['old_value']])) { + $field = $fields[$status['old_value']]; + + // Ensure claim_status is a scalar value (string or int) + $claim_status = (string)$status['claim_status']; // Cast to string to avoid issues + + // Initialize claim_status if it doesn't exist in the array + if (!isset($data_to_send[$claim_status])) { + $data_to_send[$claim_status] = []; + } + + // Handle case where $field is an array + if (is_array($field)) { + foreach ($field as $f) { + // Check if the field exists in the ticket data + $data_to_send[$claim_status][$f] = isset($ticket_data[$f]) ? $ticket_data[$f] : null; + + // Check if the field contains a date and format it + if ($this->isDate($data_to_send[$claim_status][$f])) { + $data_to_send[$claim_status][$f] = date('d-m-Y', strtotime($data_to_send[$claim_status][$f])); + } + + $this->myLogger->logme("error", "Data for field {$f}: " . json_encode($data_to_send[$claim_status][$f])); + } + } else { + // If field is not an array, handle it as a single field + $data_to_send[$claim_status][$field] = isset($ticket_data[$field]) ? $ticket_data[$field] : null; + + // Check if the field contains a date and format it + if ($this->isDate($data_to_send[$claim_status][$field])) { + $data_to_send[$claim_status][$field] = date('d-m-Y', strtotime($data_to_send[$claim_status][$field])); + } + + $this->myLogger->logme("error", "Data for field {$field}: " . json_encode($data_to_send[$claim_status][$field])); + } + } + } + + $this->myLogger->logme('error', "Total data: " . json_encode($data_to_send)); + + // Send response based on data availability + if (!empty($data_to_send)) { + return $this->respond(['status' => true, 'data' => $data_to_send], 200); + } else { + return $this->respond(['status' => false], 200); + } + } + + private function isDate($value) { + // Check if the value is a valid date string (basic validation) + return strtotime($value) !== false; + } + + + } diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index 1815316b..8eb8c494 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -11,6 +11,18 @@ background-color: #f0f0f0; color: #666; } + + .info-icon { + color: #007bff; + font-size: 15px; + transition: 0.3s ease; + cursor: pointer; + } + + .info-icon:hover { + color: #0056b3; + font-size: 24px; + }
@@ -168,7 +180,7 @@

-
Claim Details
+
Claim Details

@@ -415,6 +427,24 @@
+ + + + + \ No newline at end of file diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php index f5d700d6..3618d1f1 100644 --- a/app/Views/ticket_form_gpa.php +++ b/app/Views/ticket_form_gpa.php @@ -4,6 +4,18 @@ background-color: #e0e0e0; color: #666; } + + .info-icon { + color: #007bff; + font-size: 15px; + transition: 0.3s ease; + cursor: pointer; + } + + .info-icon:hover { + color: #0056b3; + font-size: 24px; + }
@@ -130,7 +142,7 @@

-
Claim Details
+
Claim Details

@@ -320,6 +332,23 @@
+ + + + \ No newline at end of file