From 53c16d106f407d0e515301e129de3c317b02fc47 Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Mon, 1 Sep 2025 17:27:15 +0530 Subject: [PATCH] FIX_Thz History --- app/Controllers/ThzController.php | 30 +++++++++++++++++++----------- app/Views/thz_list.php | 8 ++++++++ app/Views/thz_notes.php | 10 ++++++---- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php index 645b3ea6..e5c4c6dd 100644 --- a/app/Controllers/ThzController.php +++ b/app/Controllers/ThzController.php @@ -56,15 +56,16 @@ class ThzController extends BaseController try { $data = $this->request->getPost(); - + $references = ""; if (!empty($data['thz_id'])) { $text = "update"; - $result = $this->updateTicket($data); // here insert history Status. $old = $this->thzMasterModel->where('thz_id', $data['thz_id'])->get()->getRowArray(); + $result = $this->updateTicket($data); if ($old && isset($data['status'])) { + if ($old['status'] != $data['status']) { $history = [ 'thz_id' => $data['thz_id'], @@ -79,8 +80,13 @@ class ThzController extends BaseController $history['created_by'] = get_session_userid(); } - $this->thzHistoryModel->insert($history); + $hist_id = $this->thzHistoryModel->insert($history); + $references = $old['status']." - ".$data['status']." - ".$hist_id; + }else{ + $references = $old['status']." - ".$data['status']; } + }else{ + $references = "No Details"; } $updateID = $data['thz_id']; @@ -90,6 +96,7 @@ class ThzController extends BaseController $text = "create"; $insertID = $this->insertTicket($data); $result = true; + $references = ""; } @@ -100,7 +107,8 @@ class ThzController extends BaseController return $this->response->setJSON([ 'status' => $result ? 'success' : 'error', 'message' => $result ? "Ticket {$text}d successfully " : "Unable to {$text} ticket. Please try again." , - 'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed..!!' + 'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed..!!', + 'ref' => $references ])->setStatusCode($result ? 200 : 400); } catch (\Throwable $e) { $code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500; @@ -114,7 +122,7 @@ class ThzController extends BaseController $this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0); return $this->response->setJSON([ 'status' => 'error', 'message' => $isDbError ? 'Data Access Error' : $e->getMessage(), - 'ref' => $isDbError ? 'database' : 'application' . $code . ' / ' . $e->getLine() + 'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine() ])->setStatusCode($code); } } @@ -169,7 +177,7 @@ class ThzController extends BaseController $this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0); return $this->response->setJSON([ 'status' => 'error', 'message' => $isDbError ? 'Data Access Error' : $e->getMessage(), - 'ref' => $isDbError ? 'database' : 'application' . $code . ' / ' . $e->getLine() + 'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine() ])->setStatusCode($code); } } @@ -214,7 +222,7 @@ class ThzController extends BaseController $this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0); return $this->response->setJSON([ 'status' => 'error', 'message' => $isDbError ? 'Data Access Error' : $e->getMessage(), - 'ref' => $isDbError ? 'database' : 'application' . $code . ' / ' . $e->getLine() + 'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine() ])->setStatusCode($code); } } @@ -260,7 +268,7 @@ class ThzController extends BaseController $this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0); return $this->response->setJSON([ 'status' => 'error', 'message' => $isDbError ? 'Data Access Error' : $e->getMessage(), - 'ref' => $isDbError ? 'database' : 'application' . $code . ' / ' . $e->getLine() + 'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine() ])->setStatusCode($code); } } @@ -309,7 +317,7 @@ class ThzController extends BaseController $this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0); return $this->response->setJSON([ 'status' => 'error', 'message' => $isDbError ? 'Data Access Error' : $e->getMessage(), - 'ref' => $isDbError ? 'database' : 'application' . $code . ' / ' . $e->getLine() + 'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine() ])->setStatusCode($code); } }else{ @@ -389,7 +397,7 @@ class ThzController extends BaseController $this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0); return $this->response->setJSON([ 'status' => 'error', 'message' => $isDbError ? 'Data Access Error' : $e->getMessage(), - 'ref' => $isDbError ? 'database' : 'application' . $code . ' / ' . $e->getLine() + 'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine() ])->setStatusCode($code); } } @@ -428,7 +436,7 @@ class ThzController extends BaseController $this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0); return $this->response->setJSON([ 'status' => 'error', 'message' => $isDbError ? 'Data Access Error' : $e->getMessage(), - 'ref' => $isDbError ? 'database / ' : 'application / ' . $code . ' / ' . $e->getLine() + 'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine() ])->setStatusCode($code); } } diff --git a/app/Views/thz_list.php b/app/Views/thz_list.php index 7f2dcc2c..56dc6134 100644 --- a/app/Views/thz_list.php +++ b/app/Views/thz_list.php @@ -400,6 +400,10 @@ table.dataTable td.wrap { var form = document.getElementById("ticketForm"); // your form ID var formData = new FormData(form); + var btn = document.querySelector("button[onclick='submitTicket()']"); + btn.disabled = true; + btn.innerText = "Saving..."; + $.ajax({ url: "", type: "POST", @@ -420,6 +424,10 @@ table.dataTable td.wrap { error: function(xhr) { toastr.error("Something went wrong!", 'Error'); console.error(xhr.responseText); + }, + complete: function() { + btn.disabled = false; + btn.innerText = "Save"; } }); } diff --git a/app/Views/thz_notes.php b/app/Views/thz_notes.php index a131e7ad..99d76048 100644 --- a/app/Views/thz_notes.php +++ b/app/Views/thz_notes.php @@ -313,9 +313,9 @@ hr{
- + - +
0/1500 @@ -571,7 +571,8 @@ hr{ }); } - function submitConverstionTicket(notetype) { + function submitConverstionTicket(notetype,btn) { + btn.disabled = true; document.getElementById("notes_type").value = notetype; const urlParams = new URLSearchParams(window.location.search); @@ -610,7 +611,8 @@ hr{ error: function(xhr) { toastr.error("Something went wrong!", 'Error'); console.error(xhr.responseText); - } + }, + complete: function() { btn.disabled = false;} }); }