Merge branch 'Qloapps:develop' into hourly

This commit is contained in:
Sumit Panwar
2024-09-19 18:50:55 +05:30
committed by GitHub
6 changed files with 26 additions and 6 deletions

View File

@@ -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
*/

View File

@@ -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);

View File

@@ -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'),

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);