Merge branch 'ticket/r16159-customer-message' into develop
This commit is contained in:
commit
71d44a1eb6
@ -38,11 +38,15 @@ class AdminCustomerThreads extends AdminTab
|
||||
$this->view = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->_select = 'CONCAT(c.firstname," ",c.lastname) as customer, cl.name as contact, l.name as language, group_concat(message) as messages, (
|
||||
SELECT IFNULL(CONCAT(LEFT(e.firstname, 1),". ",e.lastname), "--")
|
||||
$this->_select = '
|
||||
CONCAT(c.firstname, " ", c.lastname) as customer, cl.name as contact,
|
||||
l.name as language, group_concat(message) as messages,
|
||||
(SELECT IFNULL(CONCAT(LEFT(e.firstname, 1), ". ", e.lastname), "--")
|
||||
FROM '._DB_PREFIX_.'customer_message cm2 INNER JOIN '._DB_PREFIX_.'employee e ON e.id_employee = cm2.id_employee
|
||||
WHERE cm2.id_employee > 0 AND cm2.`id_customer_thread` = a.`id_customer_thread`
|
||||
ORDER BY cm2.date_add DESC LIMIT 1) as employee';
|
||||
ORDER BY cm2.date_add DESC LIMIT 1
|
||||
) as employee';
|
||||
|
||||
$this->_group = 'GROUP BY cm.id_customer_thread';
|
||||
$this->_join = '
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = a.`id_customer`
|
||||
@ -92,7 +96,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
'id_product' => array('title' => $this->l('> 10€'), 'width' => 50, 'maxlength' => 0, 'align' =>'center'),
|
||||
'id_order' => array('title' => $this->l('Nb products'), 'width' => 50, 'maxlength' => 0, 'align' =>'center text-bold','search'=>false),
|
||||
'order' => array('title' => $this->l('Total cmd'), 'width' => 50, 'maxlength' => 0, 'align' =>'center text-bold'),
|
||||
'date_upd' => array('title' => $this->l('Last message'), 'width' => 50, 'type'=>'datetimeLight')
|
||||
'date_add' => array('title' => $this->l('Open at'), 'width' => 50, 'type'=>'datetimeLight')
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
@ -242,7 +246,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
$this->viewcustomer_thread();
|
||||
else
|
||||
{
|
||||
$this->getList((int)$cookie->id_lang, !Tools::getValue($this->table.'Orderby') ? 'date_upd' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
|
||||
$this->getList((int)$cookie->id_lang, !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
|
||||
$this->displayList();
|
||||
}
|
||||
}
|
||||
|
@ -173,9 +173,15 @@ if (Tools::isSubmit('submitMessage')) {
|
||||
|
||||
if ($contact->customer_service)
|
||||
{
|
||||
$ctStatusLast = false;
|
||||
|
||||
if ((int)$id_customer_thread)
|
||||
{
|
||||
$ct = new CustomerThread($id_customer_thread);
|
||||
|
||||
$ctStatusLast = $ct->status;
|
||||
$ctStatusDate = $ct->date_upd;
|
||||
|
||||
$ct->status = 'open';
|
||||
$ct->id_lang = (int)$cookie->id_lang;
|
||||
$ct->id_contact = (int)($id_contact);
|
||||
@ -213,6 +219,12 @@ if (Tools::isSubmit('submitMessage')) {
|
||||
|
||||
if ($ct->id)
|
||||
{
|
||||
// Update date_upd to the last interesting date
|
||||
if ($ctStatusLast !== false && $ctStatusLast == 'open') {
|
||||
$sql = 'UPDATE `'._DB_PREFIX_.'customer_threads` SET `date_upd` = "'.$ctStatusDate.'" WHERE id_customer_thread='. $ct->id;
|
||||
Db::getInstance()->Execute($sql);
|
||||
}
|
||||
|
||||
// adding (antadis) - linking reason and customer_thread
|
||||
if (Tools::getValue('id_reason')) {
|
||||
$id_reason = (int) Tools::getValue('id_reason');
|
||||
|
@ -169,9 +169,15 @@ class ContactController extends ContactControllerCore {
|
||||
|
||||
if ($contact->customer_service)
|
||||
{
|
||||
$ctStatusLast = false;
|
||||
|
||||
if ((int)$id_customer_thread)
|
||||
{
|
||||
$ct = new CustomerThread($id_customer_thread);
|
||||
|
||||
$ctStatusLast = $ct->status;
|
||||
$ctStatusDate = $ct->date_upd;
|
||||
|
||||
$ct->status = 'open';
|
||||
$ct->id_lang = (int)self::$cookie->id_lang;
|
||||
$ct->id_contact = (int)($id_contact);
|
||||
@ -202,6 +208,12 @@ class ContactController extends ContactControllerCore {
|
||||
|
||||
if ($ct->id)
|
||||
{
|
||||
// Update date_upd to the last interesting date
|
||||
if ($ctStatusLast !== false && $ctStatusLast == 'open') {
|
||||
$sql = 'UPDATE `'._DB_PREFIX_.'customer_threads` SET `date_upd` = "'.$ctStatusDate.'" WHERE id_customer_thread='. $ct->id;
|
||||
Db::getInstance()->Execute($sql);
|
||||
}
|
||||
|
||||
$cm = new CustomerMessage();
|
||||
$cm->id_customer_thread = $ct->id;
|
||||
$cm->message = htmlentities($message, ENT_COMPAT, 'UTF-8');
|
||||
|
Loading…
Reference in New Issue
Block a user