FIX_Thz History

This commit is contained in:
venba-Inspriron-3558 2025-09-01 17:27:15 +05:30
parent 996f3276a7
commit 53c16d106f
3 changed files with 33 additions and 15 deletions

View File

@ -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);
}
}

View File

@ -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: "<?= base_url('ticketSave') ?>",
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";
}
});
}

View File

@ -313,9 +313,9 @@ hr{
<textarea class="form-control" id="notes" name="notes" placeholder="Write your notes here..." required maxlength="1500"></textarea>
<div class="icon-buttons">
<!-- save btn means local - internal -->
<button type="button" class="btn-icon" onclick="submitConverstionTicket('Internal')"><i class="mdi mdi-content-save"></i></button>
<button type="button" class="btn-icon" onclick="submitConverstionTicket('Internal', this)"><i class="mdi mdi-content-save"></i></button>
<!-- mail btn means notify - external -->
<button type="button" class="btn-icon" onclick="submitConverstionTicket('External')"><i class="mdi mdi-email"></i></button>
<button type="button" class="btn-icon" onclick="submitConverstionTicket('External', this)"><i class="mdi mdi-email"></i></button>
</div>
</div>
<small id="messageCounter" class="form-text text-muted text-end app-text-right">0/1500</small>
@ -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;}
});
}
</script>