CHANGE_UI_Issues - VADIVEL J 2025-09-25
This commit is contained in:
parent
aecec270dc
commit
4abee8faec
@ -100,5 +100,7 @@ class Autoload extends AutoloadConfig
|
|||||||
* @var string[]
|
* @var string[]
|
||||||
* @phpstan-var list<string>
|
* @phpstan-var list<string>
|
||||||
*/
|
*/
|
||||||
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper', 'api_helper'];
|
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload',
|
||||||
|
'excel_import_export', 'file', 'drive','ExcelSanitizeHelper', 'api_helper','ExceptionHelper'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,30 +69,7 @@ class ThzController extends BaseController
|
|||||||
$old = $this->thzMasterModel->where('thz_id', $data['thz_id'])->get()->getRowArray();
|
$old = $this->thzMasterModel->where('thz_id', $data['thz_id'])->get()->getRowArray();
|
||||||
$result = $this->updateTicket($data);
|
$result = $this->updateTicket($data);
|
||||||
|
|
||||||
if ($old && isset($data['status'])) {
|
$references = ($old && isset($data['status'])) ? $this->handleTicketHistory($old, $data) : "No Details" ;
|
||||||
|
|
||||||
if ($old['status'] != $data['status']) {
|
|
||||||
$history = [
|
|
||||||
'thz_id' => $data['thz_id'],
|
|
||||||
'field_name' => 'status',
|
|
||||||
'display_name' => 'Status',
|
|
||||||
'old_value' => $old['status'],
|
|
||||||
'new_value' => $data['status'],
|
|
||||||
'is_active' => 1
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!empty(get_session_userid())) {
|
|
||||||
$history['created_by'] = get_session_userid();
|
|
||||||
}
|
|
||||||
|
|
||||||
$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'];
|
$updateID = $data['thz_id'];
|
||||||
} else {
|
} else {
|
||||||
@ -115,22 +92,10 @@ class ThzController extends BaseController
|
|||||||
'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed..!!',
|
'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed..!!',
|
||||||
'ref' => $references
|
'ref' => $references
|
||||||
])->setStatusCode($result ? 200 : 400);
|
])->setStatusCode($result ? 200 : 400);
|
||||||
|
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
|
return handle_exception($e, $this->myLogger, $this->response);
|
||||||
|
|
||||||
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|
|
||||||
|| $e instanceof \mysqli_sql_exception
|
|
||||||
|| $e instanceof \PDOException;
|
|
||||||
|
|
||||||
$context = ['title' => get_class($e), 'type' => get_class($e), 'code' => $code, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()];
|
|
||||||
|
|
||||||
$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()
|
|
||||||
])->setStatusCode($code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,21 +141,7 @@ class ThzController extends BaseController
|
|||||||
'data' => $tickets,
|
'data' => $tickets,
|
||||||
])->setStatusCode(200);
|
])->setStatusCode(200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
|
return handle_exception($e, $this->myLogger, $this->response);
|
||||||
|
|
||||||
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|
|
||||||
|| $e instanceof \mysqli_sql_exception
|
|
||||||
|| $e instanceof \PDOException;
|
|
||||||
|
|
||||||
$context = ['title' => get_class($e), 'type' => get_class($e), 'code' => $code, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()];
|
|
||||||
|
|
||||||
$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()
|
|
||||||
])->setStatusCode($code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,35 +160,19 @@ class ThzController extends BaseController
|
|||||||
throw new \RuntimeException('No tickets found', 404);
|
throw new \RuntimeException('No tickets found', 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data['notes_type'] == "External") {
|
$emailNotificationResult = ($data['notes_type'] === "External")
|
||||||
$emailNotificationResult = $this->ticketConversationSaveNotification($data);
|
? $this->ticketConversationSaveNotification($data)
|
||||||
} else {
|
: false;
|
||||||
$emailNotificationResult = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $this->response->setJSON([
|
return $this->response->setJSON([
|
||||||
'status' => $result ? 'success' : 'error',
|
'status' => $result ? 'success' : 'error',
|
||||||
'message' => $result ? "Ticket Notes created successfully" : "Unable to create ticket notes. Please try again.",
|
'message' => $result ? "Ticket Notes created successfully" : "Unable to create ticket notes. Please try again.",
|
||||||
'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed Or No Need..!!'
|
'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed Or No Need..!!'
|
||||||
])->setStatusCode($result ? 200 : 400);
|
])->setStatusCode($result ? 200 : 400);
|
||||||
|
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
|
return handle_exception($e, $this->myLogger, $this->response);
|
||||||
|
|
||||||
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|
|
||||||
|| $e instanceof \mysqli_sql_exception
|
|
||||||
|| $e instanceof \PDOException;
|
|
||||||
|
|
||||||
$context = ['title' => get_class($e), 'type' => get_class($e), 'code' => $code, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()];
|
|
||||||
|
|
||||||
$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()
|
|
||||||
])->setStatusCode($code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,21 +205,7 @@ class ThzController extends BaseController
|
|||||||
|
|
||||||
return $this->response->setJSON(['status' => 'success', 'data' => $result])->setStatusCode(200);
|
return $this->response->setJSON(['status' => 'success', 'data' => $result])->setStatusCode(200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
|
return handle_exception($e, $this->myLogger, $this->response);
|
||||||
|
|
||||||
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|
|
||||||
|| $e instanceof \mysqli_sql_exception
|
|
||||||
|| $e instanceof \PDOException;
|
|
||||||
|
|
||||||
$context = ['title' => get_class($e), 'type' => get_class($e), 'code' => $code, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()];
|
|
||||||
|
|
||||||
$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()
|
|
||||||
])->setStatusCode($code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +221,7 @@ class ThzController extends BaseController
|
|||||||
|
|
||||||
if ($thz_id) {
|
if ($thz_id) {
|
||||||
$result['master'] = $this->thzMasterModel
|
$result['master'] = $this->thzMasterModel
|
||||||
->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
|
->select('thz_master.*, user_profiles.first_name as assignee_name')
|
||||||
->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
|
->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
|
||||||
->where('thz_master.thz_id', $thz_id)
|
->where('thz_master.thz_id', $thz_id)
|
||||||
->findAll();
|
->findAll();
|
||||||
@ -321,21 +242,7 @@ class ThzController extends BaseController
|
|||||||
try {
|
try {
|
||||||
return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200);
|
return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
|
return handle_exception($e, $this->myLogger, $this->response);
|
||||||
|
|
||||||
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|
|
||||||
|| $e instanceof \mysqli_sql_exception
|
|
||||||
|| $e instanceof \PDOException;
|
|
||||||
|
|
||||||
$context = ['title' => get_class($e), 'type' => get_class($e), 'code' => $code, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()];
|
|
||||||
|
|
||||||
$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()
|
|
||||||
])->setStatusCode($code);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -347,7 +254,7 @@ class ThzController extends BaseController
|
|||||||
: '';
|
: '';
|
||||||
|
|
||||||
$result['related_tickets'] = $this->thzMasterModel
|
$result['related_tickets'] = $this->thzMasterModel
|
||||||
->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
|
->select('thz_master.*, user_profiles.first_name as assignee_name')
|
||||||
->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
|
->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
|
||||||
->where('thz_master.assign_to', $assign_to)
|
->where('thz_master.assign_to', $assign_to)
|
||||||
->where('thz_master.mobile', $mobile)
|
->where('thz_master.mobile', $mobile)
|
||||||
@ -402,21 +309,7 @@ class ThzController extends BaseController
|
|||||||
}
|
}
|
||||||
return $this->response->setJSON(['status' => 'error', 'message' => 'Invalid request method'])->setStatusCode(405);
|
return $this->response->setJSON(['status' => 'error', 'message' => 'Invalid request method'])->setStatusCode(405);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
|
return handle_exception($e, $this->myLogger, $this->response);
|
||||||
|
|
||||||
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|
|
||||||
|| $e instanceof \mysqli_sql_exception
|
|
||||||
|| $e instanceof \PDOException;
|
|
||||||
|
|
||||||
$context = ['title' => get_class($e), 'type' => get_class($e), 'code' => $code, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()];
|
|
||||||
|
|
||||||
$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()
|
|
||||||
])->setStatusCode($code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +319,7 @@ class ThzController extends BaseController
|
|||||||
$data = $this->request->getGet();
|
$data = $this->request->getGet();
|
||||||
$thz_id = $data['thz_id'];
|
$thz_id = $data['thz_id'];
|
||||||
// $details = $this->thzHistoryModal->whereIn('thz_id', $thz_id)->where('is_active', 1)->get()->getResultArray();
|
// $details = $this->thzHistoryModal->whereIn('thz_id', $thz_id)->where('is_active', 1)->get()->getResultArray();
|
||||||
$details = $this->thzHistoryModel->select('thz_history.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as created_name')
|
$details = $this->thzHistoryModel->select('thz_history.*, user_profiles.first_name as created_name')
|
||||||
->join('user_profiles', 'user_profiles.id = thz_history.created_by', 'left')
|
->join('user_profiles', 'user_profiles.id = thz_history.created_by', 'left')
|
||||||
->where('thz_history.thz_id', $thz_id)->where('thz_history.is_active', 1)
|
->where('thz_history.thz_id', $thz_id)->where('thz_history.is_active', 1)
|
||||||
->orderBy('thz_history.created_at', 'desc')
|
->orderBy('thz_history.created_at', 'desc')
|
||||||
@ -442,21 +335,7 @@ class ThzController extends BaseController
|
|||||||
|
|
||||||
return $this->response->setJSON(['status' => 'success', 'data' => $details])->setStatusCode(200);
|
return $this->response->setJSON(['status' => 'success', 'data' => $details])->setStatusCode(200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
|
return handle_exception($e, $this->myLogger, $this->response);
|
||||||
|
|
||||||
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|
|
||||||
|| $e instanceof \mysqli_sql_exception
|
|
||||||
|| $e instanceof \PDOException;
|
|
||||||
|
|
||||||
$context = ['title' => get_class($e), 'type' => get_class($e), 'code' => $code, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()];
|
|
||||||
|
|
||||||
$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()
|
|
||||||
])->setStatusCode($code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,7 +603,6 @@ class ThzController extends BaseController
|
|||||||
$res = MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $to_mail, 'cc' => $cc_string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]);
|
$res = MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $to_mail, 'cc' => $cc_string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]);
|
||||||
|
|
||||||
$this->myLogger->logme('error', 'Mail Response : ' . json_encode($res));
|
$this->myLogger->logme('error', 'Mail Response : ' . json_encode($res));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -744,4 +622,34 @@ class ThzController extends BaseController
|
|||||||
$data['policy_terms'] = $policy_terms;
|
$data['policy_terms'] = $policy_terms;
|
||||||
return view('view_policy_terms', $data);
|
return view('view_policy_terms', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function handleTicketHistory(array $old, array $data): string
|
||||||
|
{
|
||||||
|
if ($old['status'] != $data['status']) {
|
||||||
|
$history = [
|
||||||
|
'thz_id' => $data['thz_id'],
|
||||||
|
'field_name' => 'status',
|
||||||
|
'display_name' => 'Status',
|
||||||
|
'old_value' => $old['status'],
|
||||||
|
'new_value' => $data['status'],
|
||||||
|
'is_active' => 1
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty(get_session_userid())) {
|
||||||
|
$history['created_by'] = get_session_userid();
|
||||||
|
}
|
||||||
|
|
||||||
|
$hist_id = $this->thzHistoryModel->insert($history);
|
||||||
|
|
||||||
|
return $old['status'] . " - " . $data['status'] . " - " . $hist_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $old['status'] . " - " . $data['status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
35
app/Helpers/ExceptionHelper.php
Normal file
35
app/Helpers/ExceptionHelper.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// app/Helpers/ExceptionHelper.php
|
||||||
|
if (!function_exists('handle_exception')) {
|
||||||
|
function handle_exception(Throwable $e, $logger = null, $response = null)
|
||||||
|
{
|
||||||
|
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
|
||||||
|
|
||||||
|
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|
||||||
|
|| $e instanceof \mysqli_sql_exception
|
||||||
|
|| $e instanceof \PDOException;
|
||||||
|
|
||||||
|
$context = [
|
||||||
|
'title' => get_class($e),
|
||||||
|
'type' => get_class($e),
|
||||||
|
'code' => $code,
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'file' => $e->getFile(),
|
||||||
|
'line' => $e->getLine()
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($logger) {
|
||||||
|
$logger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0);
|
||||||
|
} else {
|
||||||
|
log_message('error', "Exception: {$context['message']} in {$context['file']} on line {$context['line']}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->setJSON([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => $isDbError ? 'Data Access Error' : $e->getMessage(),
|
||||||
|
'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine()
|
||||||
|
])->setStatusCode($code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user