From b42e314d5b37440321619bea9ca496a82d8fe91f Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 17 Sep 2024 20:04:43 +0530 Subject: [PATCH] Optimized the code for the customer messages --- classes/CustomerMessage.php | 2 ++ classes/CustomerThread.php | 10 ++++------ controllers/admin/AdminOrdersController.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/CustomerMessage.php b/classes/CustomerMessage.php index 99522fa0d..3406a60ef 100644 --- a/classes/CustomerMessage.php +++ b/classes/CustomerMessage.php @@ -37,6 +37,8 @@ class CustomerMessageCore extends ObjectModel public $date_add; public $date_upd; public $read; + const QLO_CUSTOMER_MESSAGE_BY_ADMIN = 1; + const QLO_CUSTOMER_MESSAGE_BY_ADMIN_CUSTOMER = 2; /** * @see ObjectModel::$definition diff --git a/classes/CustomerThread.php b/classes/CustomerThread.php index cfc1772c0..ef4d99c4a 100644 --- a/classes/CustomerThread.php +++ b/classes/CustomerThread.php @@ -38,8 +38,6 @@ class CustomerThreadCore extends ObjectModel public $token; public $date_add; public $date_upd; - const QLO_CUSTOMER_THREAD_TYPE_SENT = 1; - const QLO_CUSTOMER_THREAD_TYPE_RECEIVED = 2; /** * @see ObjectModel::$definition @@ -122,7 +120,7 @@ class CustomerThreadCore extends ObjectModel return $return; } - public static function getCustomerMessages($id_customer, $read = null, $id_order = null, $threadType = null) + public static function getCustomerMessages($id_customer, $read = null, $id_order = null, $messageBy = null) { $sql = 'SELECT * FROM '._DB_PREFIX_.'customer_thread ct @@ -137,10 +135,10 @@ class CustomerThreadCore extends ObjectModel $sql .= ' AND ct.`id_order` = '.(int)$id_order; } - if ($threadType != null) { - if (self::QLO_CUSTOMER_THREAD_TYPE_SENT == $threadType) { + if ($messageBy !== null) { + if (CustomerMessage::QLO_CUSTOMER_MESSAGE_BY_ADMIN == $messageBy) { $sql .= ' AND cm.`id_employee` != 0'; - } else if (self::QLO_CUSTOMER_THREAD_TYPE_RECEIVED == $threadType) { + } else if (CustomerMessage::QLO_CUSTOMER_MESSAGE_BY_ADMIN_CUSTOMER == $messageBy) { $sql .= ' AND cm.`id_employee` = 0'; } } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index faa6183f3..d490e1b9b 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -2431,7 +2431,7 @@ class AdminOrdersControllerCore extends AdminController $helper->title = $this->l('Messages'); $helper->tooltip = $this->l('Messages is the number of customer messages for this order.'); $helper->href = $this->context->link->getAdminLink('AdminCustomerThreads').'&id_order='.$objOrder->id; - $helper->value = count(CustomerThread::getCustomerMessages($objOrder->id_customer, null, $objOrder->id, CustomerThread::QLO_CUSTOMER_THREAD_TYPE_RECEIVED)); + $helper->value = count(CustomerThread::getCustomerMessages($objOrder->id_customer, null, $objOrder->id, CustomerMessage::QLO_CUSTOMER_MESSAGE_BY_ADMIN)); $this->kpis[] = $helper; $objHotelBookingDetail = new HotelBookingDetail();