diff --git a/source/packages/com_mokosuite/admin/sql/install.mysql.sql b/source/packages/com_mokosuite/admin/sql/install.mysql.sql index dca5aaa2..15f07803 100644 --- a/source/packages/com_mokosuite/admin/sql/install.mysql.sql +++ b/source/packages/com_mokosuite/admin/sql/install.mysql.sql @@ -72,6 +72,9 @@ CREATE TABLE IF NOT EXISTS `#__mokosuite_tickets` ( `sla_response_due` DATETIME DEFAULT NULL, `sla_resolution_due` DATETIME DEFAULT NULL, `sla_responded` TINYINT NOT NULL DEFAULT 0, + `satisfaction_rating` TINYINT UNSIGNED DEFAULT NULL, + `satisfaction_feedback` TEXT DEFAULT NULL, + `satisfaction_rated_at` DATETIME DEFAULT NULL, PRIMARY KEY (`id`), KEY `idx_status` (`status`), KEY `idx_status_id` (`status_id`), diff --git a/source/packages/com_mokosuite/admin/src/Controller/DisplayController.php b/source/packages/com_mokosuite/admin/src/Controller/DisplayController.php index 8fa94766..2fa5942a 100644 --- a/source/packages/com_mokosuite/admin/src/Controller/DisplayController.php +++ b/source/packages/com_mokosuite/admin/src/Controller/DisplayController.php @@ -621,6 +621,28 @@ class DisplayController extends BaseController $this->jsonResponse(['success' => $ok, 'message' => $ok ? 'Attachment deleted' : 'Not found']); } + public function rateTicket() + { + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + $input = Factory::getApplication()->getInput(); + $ticketId = $input->getInt('ticket_id', 0); + $rating = $input->getInt('rating', 0); + $feedback = $input->getString('feedback', ''); + if (!$ticketId || $rating < 1 || $rating > 5) { + $this->jsonResponse(['success' => false, 'message' => 'Invalid rating (1-5)']); + return; + } + $db = Factory::getDbo(); + $db->setQuery( + 'UPDATE ' . $db->quoteName('#__mokosuite_tickets') + . ' SET satisfaction_rating = ' . $rating + . ', satisfaction_feedback = ' . $db->quote($feedback) + . ', satisfaction_rated_at = ' . $db->quote(Factory::getDate()->toSql()) + . ' WHERE id = ' . $ticketId + )->execute(); + $this->jsonResponse(['success' => true, 'message' => 'Thank you for your feedback!']); + } + public function saveAutomation() { Session::checkToken() or die(Text::_('JINVALID_TOKEN')); diff --git a/source/packages/com_mokosuite/admin/tmpl/ticket/default.php b/source/packages/com_mokosuite/admin/tmpl/ticket/default.php index c6681f06..226c6244 100644 --- a/source/packages/com_mokosuite/admin/tmpl/ticket/default.php +++ b/source/packages/com_mokosuite/admin/tmpl/ticket/default.php @@ -188,6 +188,45 @@ $priorities = $this->priorities ?? []; + + status, ['resolved', 'closed'], true); + $hasRating = !empty($t->satisfaction_rating); + ?> + +
escape($t->satisfaction_feedback); ?>
+ +