// fix refactoring templates in AdminCustomerThreadsController

This commit is contained in:
lLefevre
2011-12-02 11:19:03 +00:00
parent a85c5d4cd2
commit 70fc45a18d
18 changed files with 1138 additions and 520 deletions
+40 -15
View File
@@ -36,10 +36,10 @@ class CustomerMessageCore extends ObjectModel
public $user_agent;
public $private;
public $date_add;
protected $table = 'customer_message';
protected $identifier = 'id_customer_message';
protected $fieldsRequired = array('message');
protected $fieldsSize = array('message' => 65000);
protected $fieldsValidate = array('message' => 'isCleanHtml', 'id_employee' => 'isUnsignedId', 'ip_address' => 'isIp2Long');
@@ -47,29 +47,54 @@ class CustomerMessageCore extends ObjectModel
public function getFields()
{
$this->validateFields();
$fields['id_customer_thread'] = (int)($this->id_customer_thread);
$fields['id_employee'] = (int)($this->id_employee);
$fields['id_customer_thread'] = (int)$this->id_customer_thread;
$fields['id_employee'] = (int)$this->id_employee;
$fields['message'] = pSQL($this->message);
$fields['file_name'] = pSQL($this->file_name);
$fields['ip_address'] = (int)($this->ip_address);
$fields['ip_address'] = (int)$this->ip_address;
$fields['user_agent'] = pSQL($this->user_agent);
$fields['private'] = pSQL($this->private);
$fields['date_add'] = pSQL($this->date_add);
return $fields;
}
public static function getMessagesByOrderId($id_order, $private = true)
{
return Db::getInstance()->executeS('
SELECT cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname, (COUNT(cm.id_customer_message) = 0 AND ct.id_customer != 0) AS is_new_for_me
FROM `'._DB_PREFIX_.'customer_message` cm
LEFT JOIN `'._DB_PREFIX_.'customer_thread` ct ON ct.`id_customer_thread` = cm.`id_customer_thread`
LEFT JOIN `'._DB_PREFIX_.'customer` c ON ct.`id_customer` = c.`id_customer`
LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = cm.`id_employee`
WHERE ct.id_order = '.(int)$id_order.' AND '.(!$private ? 'cm.`private` = 0' : '').'
GROUP BY cm.id_customer_message
ORDER BY cm.date_add DESC');
SELECT cm.*,
c.`firstname` AS cfirstname,
c.`lastname` AS clastname,
e.`firstname` AS efirstname,
e.`lastname` AS elastname,
(COUNT(cm.id_customer_message) = 0 AND ct.id_customer != 0) AS is_new_for_me
FROM `'._DB_PREFIX_.'customer_message` cm
LEFT JOIN `'._DB_PREFIX_.'customer_thread` ct
ON ct.`id_customer_thread` = cm.`id_customer_thread`
LEFT JOIN `'._DB_PREFIX_.'customer` c
ON ct.`id_customer` = c.`id_customer`
LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e
ON e.`id_employee` = cm.`id_employee`
WHERE ct.id_order = '.(int)$id_order.'
AND '.(!$private ? 'cm.`private` = 0' : '').'
GROUP BY cm.id_customer_message
ORDER BY cm.date_add DESC
');
}
public static function getTotalCustomerMessages($where = null)
{
if (is_null($where))
return (int)Db::getInstance()->getValue('
SELECT COUNT(*)
FROM '._DB_PREFIX_.'customer_message
');
else
return (int)Db::getInstance()->getValue(sprintf('
SELECT COUNT(*)
FROM '._DB_PREFIX_.'customer_message
WHERE %s
', $where));
}
}