diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php index 29f89df4..d0151013 100644 --- a/app/Controllers/ThzController.php +++ b/app/Controllers/ThzController.php @@ -108,7 +108,7 @@ class ThzController extends BaseController $data = $this->request->getGet(); - if ($returnType === 'web' && in_array(get_role_id(), [3, 4])) { + if ($returnType === 'web' && in_array(get_role_id(), [4])) { $data['assign_to'] = $data['assign_to'] ?? get_session_userid(); } diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 18018d3c..87620e51 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -26,6 +26,7 @@ use App\Models\VehicleModel; use App\Models\PartnerPolicyModel; use DOMDocument; +use DOMXPath; use Psr\Log\LoggerInterface; use Kint\Kint; @@ -1313,7 +1314,7 @@ class TicketController extends BaseController } } - public function convertHtmlToText($html) + public function convertHtmlToTextOld($html) { if(!empty($html)){ $dom = new DOMDocument(); @@ -1324,6 +1325,36 @@ class TicketController extends BaseController } } + public function convertHtmlToText($html) + { + if (empty($html)) { + return ''; + } + + // Remove BOM / strange characters + $html = preg_replace('/[\x00-\x1F\x80-\xFF]/', ' ', $html); + + // Load HTML safely + $dom = new DOMDocument(); + libxml_use_internal_errors(true); + $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); + + // Remove style and script tags + $xpath = new DOMXPath($dom); + foreach ($xpath->query('//style|//script') as $node) { + $node->parentNode->removeChild($node); + } + + // Extract clean text + $text = $dom->textContent; + + // Clean extra spaces + $text = preg_replace('/\s+/', ' ', $text); + + return trim($text); + } + + public function removeTicket() { $ticket_id = $this->request->getGet('ticket_id'); diff --git a/app/Views/UserList.php b/app/Views/UserList.php index a991670d..adf1a29d 100755 --- a/app/Views/UserList.php +++ b/app/Views/UserList.php @@ -440,7 +440,7 @@ table.dataTable tbody td {
= $message['mail_content'] ?>
@@ -69,7 +69,7 @@= $message['mail_content'] ?>
diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index 02f9dfb6..c6ddf052 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -333,7 +333,7 @@