diff --git a/classes/CustomerMessage.php b/classes/CustomerMessage.php index 99522fa0d..a4b6c920d 100644 --- a/classes/CustomerMessage.php +++ b/classes/CustomerMessage.php @@ -38,6 +38,9 @@ class CustomerMessageCore extends ObjectModel public $date_upd; public $read; + const QLO_CUSTOMER_MESSAGE_BY_EMPLOYEE = 1; + const QLO_CUSTOMER_MESSAGE_BY_CUSTOMER = 2; + /** * @see ObjectModel::$definition */ diff --git a/classes/CustomerThread.php b/classes/CustomerThread.php index 70db8c507..7e1b721af 100644 --- a/classes/CustomerThread.php +++ b/classes/CustomerThread.php @@ -120,7 +120,17 @@ class CustomerThreadCore extends ObjectModel return $return; } - public static function getCustomerMessages($id_customer, $read = null, $id_order = null) + /** + * Retrieves customer messages based on specified conditions. + * + * @param int $id_customer Customer ID. + * @param bool|null $read Return read (true), unread (false), or all messages (null). + * @param int|null $id_order Filter messages by order ID. + * @param int|null $messageBy Filter messages by sender (employees, customer, or both). + * + * @return array List of messages matching the conditions. + */ + public static function getCustomerMessages($id_customer, $read = null, $id_order = null, $messageBy = null) { $sql = 'SELECT * FROM '._DB_PREFIX_.'customer_thread ct @@ -135,6 +145,14 @@ class CustomerThreadCore extends ObjectModel $sql .= ' AND ct.`id_order` = '.(int)$id_order; } + if ($messageBy !== null) { + if (CustomerMessage::QLO_CUSTOMER_MESSAGE_BY_EMPLOYEE == $messageBy) { + $sql .= ' AND cm.`id_employee` != 0'; + } else if (CustomerMessage::QLO_CUSTOMER_MESSAGE_BY_CUSTOMER == $messageBy) { + $sql .= ' AND cm.`id_employee` = 0'; + } + } + $sql .= ' ORDER BY cm.date_add DESC'; return Db::getInstance()->executeS($sql); diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index ae8553e62..c523ffd3c 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -82,7 +82,6 @@ class AdminCustomersControllerCore extends AdminController $this->_join .= ' LEFT JOIN '._DB_PREFIX_.'orders o ON (a.id_customer = o.id_customer)'; $this->_group = 'GROUP BY a.`id_customer`'; - $this->_use_found_rows = false; $this->fields_list = array( 'id_customer' => array( 'title' => $this->l('ID'), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index bccf13cb8..dc3b84236 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)); + $helper->value = count(CustomerThread::getCustomerMessages($objOrder->id_customer, null, $objOrder->id, CustomerMessage::QLO_CUSTOMER_MESSAGE_BY_CUSTOMER)); $this->kpis[] = $helper; $objHotelBookingDetail = new HotelBookingDetail(); diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index b591ade62..109e93623 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -366,7 +366,7 @@ class AdminStatsControllerCore extends AdminStatsTabController SELECT SUM(IF(c.id_gender IS NOT NULL, 1, 0)) as total, SUM(IF(type = 0, 1, 0)) as male, SUM(IF(type = 1, 1, 0)) as female, SUM(IF(type = 2, 1, 0)) as neutral FROM `'._DB_PREFIX_.'customer` c LEFT JOIN `'._DB_PREFIX_.'gender` g ON c.id_gender = g.id_gender - WHERE c.active = 1 AND c.deleted = 0 '.Shop::addSqlRestriction()); + WHERE 1 AND c.deleted = 0 '.Shop::addSqlRestriction()); if (!$row['total']) { return false; diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php index 4c7e7b6fc..948364253 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php @@ -748,9 +748,9 @@ class HotelRoomTypeFeaturePricing extends ObjectModel 0, 0, null, + 1, null, - null, - null, + Product::PRICE_ADDITION_TYPE_WITH_ROOM, $id_room )) { $selectedServices = array_shift($roomServicesServices);