From 204a683284e283b9bc78766d826abe020f219103 Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Sat, 30 Aug 2025 11:57:14 +0530 Subject: [PATCH 1/3] FIX_THZ Ticket Type --- app/Config/Routes.php | 1 + app/Controllers/ThzController.php | 220 +++++++++++++++++++++++------- app/Views/thz_list.php | 29 ++-- app/Views/thz_notes.php | 11 +- 4 files changed, 198 insertions(+), 63 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0e4c1f27..9eaf2c54 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -564,6 +564,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("ticketConversationSave", "ThzController::ticketConversationSave"); $routes->get("ticketConversationList", "ThzController::ticketConversationList"); $routes->get("ticketHistoryList", "ThzController::ticketHistoryList"); + $routes->match(['get','post','put'], 'ticketType', 'ThzController::ticketType'); $routes->get("hrFileList", "EmployeeRestController::hrFileList"); $routes->get("hrFileUploadMasters", "EmployeeRestController::hrFileUploadMasters"); diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php index ad3633e2..645b3ea6 100644 --- a/app/Controllers/ThzController.php +++ b/app/Controllers/ThzController.php @@ -31,6 +31,7 @@ class ThzController extends BaseController protected $clientModel; protected $ticketMailTemplateModel; + protected $myLogger; public function __construct() { @@ -43,6 +44,7 @@ class ThzController extends BaseController $this->clientPolicyModel = new ClientPolicyModel(); $this->clientModel = new ClientModel(); $this->ticketMailTemplateModel = new TicketMailTemplateModel(); + $this->myLogger = \Config\Services::mylogger(); } public function index() @@ -51,7 +53,8 @@ class ThzController extends BaseController } public function ticketSave(){ - + try + { $data = $this->request->getPost(); if (!empty($data['thz_id'])) { @@ -99,11 +102,27 @@ class ThzController extends BaseController 'message' => $result ? "Ticket {$text}d successfully " : "Unable to {$text} ticket. Please try again." , 'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed..!!' ])->setStatusCode($result ? 200 : 400); + } catch (\Throwable $e) { + $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()]; + + $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); + } } public function ticketList() { + try{ $returnType = strtolower($this->request->getGet('return_type') ?? 'api'); @@ -117,7 +136,8 @@ class ThzController extends BaseController if ($returnType === 'api') { if (empty($tickets)) { - return $this->response->setJSON([ 'status' => 'error','message' => 'No tickets found'])->setStatusCode(404); + // return $this->response->setJSON([ 'status' => 'error','message' => 'No tickets found'])->setStatusCode(404); + throw new \RuntimeException('No tickets found', 400); } }else{ @@ -126,18 +146,37 @@ class ThzController extends BaseController $data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu // 2,3,4 remain person varannum. $data['client_list'] = $this->clientModel->getCreatedByUserName(); + $data['ticket_type'] = $this->thzTypeModel->where('is_active', 1)->findAll(); return $this->loadLayout('thz_list', $data); } + return $this->response->setJSON([ 'status' => 'success', 'data' => $tickets, ])->setStatusCode(200); + } + catch (\Throwable $e) { + $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()]; + + $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); + } } public function ticketConversationSave(){ + try { $data = $this->request->getPost(); $data['notes_type'] = $data['notes_type'] ?? 'External' ; @@ -145,7 +184,8 @@ class ThzController extends BaseController $result = $this->thzMasterNotesModel->insert($data); if(empty($result)){ - return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404); + // return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404); + throw new \RuntimeException('No tickets found', 404); } if($data['notes_type'] == "External"){ @@ -161,41 +201,72 @@ class ThzController extends BaseController '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..!!' ])->setStatusCode($result ? 200 : 400); + } + catch (\Throwable $e) { + $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()]; + + $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); + } } - public function ticketAutoFetchDetails(){ + public function ticketAutoFetchDetails() + { + try { $data = $this->request->getPost(); - $client_id = $data['client_id']; - $mobile = $data['mobile']; + $client_id = $data['client_id'] ?? null; + $mobile = $data['mobile'] ?? null; - if($client_id && $mobile){ - - $details = $this->thzMasterModel->ticketAutoFetchDetails($client_id ,$mobile); - - if(empty($details)){ - return $this->response->setJSON((['status' => 'error', 'message' => 'No Data found']))->setStatusCode(400); - }else{ - - $policyIds = array_column($details, 'policy_id'); - $policyIds = array_filter($policyIds); - $clientPolicy = $this->clientPolicyModel->whereIn('id', $policyIds)->where('is_active', 1)->get()->getResultArray(); - $result['client_details'] = $details; - $result['policy_details'] = empty($clientPolicy) ? [] : $clientPolicy ; + if ($client_id && $mobile) { + $details = $this->thzMasterModel->ticketAutoFetchDetails($client_id, $mobile); + if (empty($details)) { + throw new \RuntimeException('No Data found', 400); } - }else{ - return $this->response->setJSON((['status' => 'error', 'message' => 'Client and Mobile Not found']))->setStatusCode(400); - } - - return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200); - + $policyIds = array_filter(array_column($details, 'policy_id')); + $clientPolicy = !empty($policyIds) + ? $this->clientPolicyModel->whereIn('id', $policyIds)->where('is_active', 1)->get()->getResultArray() + : []; + + $result['client_details'] = $details; + $result['policy_details'] = $clientPolicy ?? []; + } else { + throw new \RuntimeException('Client and Mobile Not found', 400); + } + + return $this->response->setJSON(['status' => 'success', 'data' => $result])->setStatusCode(200); + + } + catch (\Throwable $e) { + $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()]; + + $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); + } } - public function ticketConversationList(){ - + public function ticketConversationList() + { $data = $this->request->getGet(); $returnType = strtolower($this->request->getGet('return_type') ?? 'api'); @@ -215,16 +286,32 @@ class ThzController extends BaseController $notes = $this->thzMasterNotesModel->ticketConversationList($thz_id, $returnType ); $result['notes'] = !empty($notes) ? $notes : []; }else{ - return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(400); + // return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(400); + throw new \RuntimeException('No tickets found', 400); } }else{ - return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404); + // return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404); + throw new \RuntimeException('No tickets found', 404); } - - if ($returnType === 'api') { - return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200); + try { + return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200); + } catch (\Throwable $e) { + $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()]; + + $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{ $assign_to = $result['master'][0]['assign_to']; @@ -247,24 +334,24 @@ class ThzController extends BaseController $result['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu // 2,3,4 remain person varannum. $result['policy_terms'] = $toGetPolicyId ? $this->getPolicyTerms($toGetPolicyId) : ''; + + $result['ticket_type'] = $this->thzTypeModel->where('is_active', 1)->findAll(); return $this->loadLayout('thz_notes', $result); - } - + + } } public function ticketType() { - $method = $this->request->getMethod(); // get, post - - if ($method === 'get') { - - $types = $this->thzTypeModel->where('is_active', 1)->findAll(); + $method = $this->request->getMethod(); // get, post + try{ + if ($method === 'get') { + $types = $this->thzTypeModel->select('id,name,is_active')->where('is_active', 1)->findAll(); if (empty($types)) { return $this->response->setJSON(['status' => 'error','message' => 'No ticket types found'])->setStatusCode(404); } return $this->response->setJSON(['status' => 'success','data' => $types])->setStatusCode(200); - } if ($method === 'post') { @@ -280,20 +367,37 @@ class ThzController extends BaseController $result = true; } - $id = isset($insertID) && !empty($insertID) ? $insertID : $updateID ; + $id = isset($insertID) && !empty($insertID) ? $insertID : ($updateID ?? null); - return $this->response->setJSON([ - 'status' => $id ? 'success' : 'error', - 'message' => $id ? "Ticket Type {$text}d successfully " : "Unable to {$text} ticket type. Please try again." , - 'id' => $id + return $this->response->setJSON([ + 'status' => $id ? 'success' : 'error', + 'message' => $id ? "Ticket Type {$text}d successfully" : "Unable to {$text} ticket type. Please try again.", + 'id' => $id ])->setStatusCode($id ? 200 : 400); - } - return $this->response->setJSON(['status' => 'error','message' => 'No ticket types found'])->setStatusCode(404); + } + return $this->response->setJSON([ 'status' => 'error', 'message' => 'Invalid request method' ])->setStatusCode(405); + } + catch (\Throwable $e) { + $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()]; + + $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); + } } public function ticketHistoryList() { - + try + { $data = $this->request->getGet(); $thz_id = $data['thz_id']; // $details = $this->thzHistoryModal->whereIn('thz_id', $thz_id)->where('is_active', 1)->get()->getResultArray(); @@ -306,11 +410,27 @@ class ThzController extends BaseController if (empty($details)) { - return $this->response->setJSON([ 'status' => 'error','message' => 'No History found'])->setStatusCode(404); + // return $this->response->setJSON([ 'status' => 'error','message' => 'No History found'])->setStatusCode(404); + throw new \RuntimeException('No History found', 404); } - return $this->response->setJSON(['status' => 'success','data' => $details])->setStatusCode(200); + return $this->response->setJSON(['status' => 'success','data' => $details])->setStatusCode(200); + } catch (\Throwable $e) { + $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()]; + + $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); + } } diff --git a/app/Views/thz_list.php b/app/Views/thz_list.php index b38798ac..1057ad26 100644 --- a/app/Views/thz_list.php +++ b/app/Views/thz_list.php @@ -7,8 +7,17 @@ width: 100%; } +/* .table thead th { + vertical-align: bottom; + border-bottom: 2px solid #fff; +} */ +/* Add shadow + spacing row "card" effect */ +tbody tr { + /* box-shadow: 0 2px 5px rgba(0,0,0,0.08); */ +} + /* Search input with icon */ .dataTables_filter { position: absolute; @@ -196,7 +205,7 @@ table thead th {
- +
@@ -341,17 +350,17 @@ table thead th { @@ -725,15 +734,14 @@ $(document).ready(function() { hideandshowpolicy(); var ticketsTable = $('#scroll-horizontal-datatable'); - $('#scroll-horizontal-datatable_filter').prepend(''); if (ticketsTable.length) { ticketsTable.DataTable({ scrollX: true, - dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + - "<'row'<'col-sm-12'tr>>" + - "<'row'<'col-sm-5'i><'col-sm-7'p>>", + dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" + + "<'row'<'col-sm-12'tr>>" + + "<'row'<'col-sm-5'i><'col-sm-7'p>>", buttons: [ { text: ' Create New Ticket ', @@ -775,7 +783,6 @@ $(document).ready(function() { }, paging: true, pageLength: 25, - ordering: false, }); } else { diff --git a/app/Views/thz_notes.php b/app/Views/thz_notes.php index 2a5720b7..03b2aa66 100644 --- a/app/Views/thz_notes.php +++ b/app/Views/thz_notes.php @@ -347,8 +347,15 @@ hr{ From 782dd2eb7078b90e20561b9648d1489cd9282046 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Sat, 30 Aug 2025 12:47:45 +0530 Subject: [PATCH 2/3] CHANGE_UI_FIX - VADIVEL J 2025-08-30 --- app/Controllers/LeadsController.php | 2 +- app/Views/layout/header.php | 24 ++-- app/Views/view_rfq.php | 140 ++++++++++++++-------- app/Views/view_rfq_non_eb.php | 18 +-- public/assets/js/pages/foo-tables.init.js | 2 +- 5 files changed, 111 insertions(+), 75 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index db3e331d..6590496c 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -4902,7 +4902,7 @@ class LeadsController extends BaseController // Start table with clean styling $html .= "

{$category}

"; - $html .= "
Ticket ID
"; + $html .= "
"; // Table header with light background $html .= ""; diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 5783afbf..35ad766e 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -97,17 +97,7 @@