diff --git a/admin/themes/default/template/controllers/customer_threads/helpers/view/view.tpl b/admin/themes/default/template/controllers/customer_threads/helpers/view/view.tpl index fb68b64e7..6cb1f5885 100644 --- a/admin/themes/default/template/controllers/customer_threads/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/customer_threads/helpers/view/view.tpl @@ -111,8 +111,8 @@ {l s="Choose a template"} --> - - + + diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index b823f98a1..95bbe3d36 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -703,13 +703,13 @@ {* Order Internal notes *} - {if (sizeof($messages))} + {if isset($messages) && $messages}
-  {l s='Order Notes'} +  {l s='Order Private Notes'}
- {foreach from=$messages item=message} + {foreach from=$messages item=message name=customerMessage}

{$message['message']|escape:'html':'UTF-8'|nl2br} @@ -726,6 +726,7 @@ {/if}

+ {if !$smarty.foreach.customerMessage.last}
{/if} {* {if ($message['is_new_for_me'])} diff --git a/classes/CustomerMessage.php b/classes/CustomerMessage.php index 6ac21bbef..abc6df3ef 100644 --- a/classes/CustomerMessage.php +++ b/classes/CustomerMessage.php @@ -74,7 +74,7 @@ class CustomerMessageCore extends ObjectModel ), ); - public static function getMessagesByOrderId($id_order, $private = true, $limit = false) + public static function getMessagesByOrderId($id_order, $private = null, $limit = false) { return Db::getInstance()->executeS(' SELECT cm.*, @@ -91,7 +91,7 @@ class CustomerMessageCore extends ObjectModel LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = cm.`id_employee` WHERE ct.id_order = '.(int)$id_order.' - '.(!$private ? 'AND cm.`private` = 0' : '').' + '.(!is_null($private) ? 'AND cm.`private` = '.(int) $private : '').' GROUP BY cm.id_customer_message ORDER BY cm.date_add DESC'. (($limit) ? ' LIMIT '.(int) $limit: ' ') diff --git a/classes/CustomerThread.php b/classes/CustomerThread.php index 367499a0a..04fb60851 100644 --- a/classes/CustomerThread.php +++ b/classes/CustomerThread.php @@ -30,6 +30,7 @@ class CustomerThreadCore extends ObjectModel public $id_shop; public $id_lang; public $id_contact; + public $id_employee; public $id_customer; public $id_order; public $user_name; @@ -60,6 +61,7 @@ class CustomerThreadCore extends ObjectModel 'subject' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'), 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_customer' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_employee' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 254), 'token' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true), diff --git a/classes/Message.php b/classes/Message.php index 0d1deaf2d..42a16bc54 100644 --- a/classes/Message.php +++ b/classes/Message.php @@ -88,7 +88,7 @@ class MessageCore extends ObjectModel * @param bool $private return WITH private messages * @return array Messages */ - public static function getMessagesByOrderId($id_order, $private = false, Context $context = null) + public static function getMessagesByOrderId($id_order, $private = null, Context $context = null) { if (!Validate::isBool($private)) { die(Tools::displayError()); @@ -108,7 +108,7 @@ class MessageCore extends ObjectModel AND mr.`id_employee` = '.(isset($context->employee) ? (int)$context->employee->id : '\'\'').' LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee` WHERE id_order = '.(int)$id_order.' - '.(!$private ? ' AND m.`private` = 0' : '').' + '.(!is_null($private) ? ' AND m.`private` = '.(int) $private : '').' GROUP BY m.id_message ORDER BY m.date_add DESC '); diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index 8d3580781..72c8b3447 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -2610,7 +2610,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $message = strip_tags($remark, '
'); $saveMessage = true; $idCart = Cart::getCartIdByOrderId($objOrder->id); - if ($customerMessages = Message::getMessagesByOrderId($objOrder->id, true)) { + if ($customerMessages = Message::getMessagesByOrderId($objOrder->id, false)) { foreach ($customerMessages as $customerMessage) { if ($customerMessage['message'] == $message) { $saveMessage = false; @@ -3424,7 +3424,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We } $params['associations']['remarks'] = array(); - if ($customerMessages = Message::getMessagesByOrderId($objOrder->id, true)) { + if ($customerMessages = Message::getMessagesByOrderId($objOrder->id)) { foreach ($customerMessages as $customerMessage) { $message = $customerMessage['message']; $params['associations']['remarks'][] = $message; diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index dddc015d9..7f2940ec1 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -114,10 +114,10 @@ class AdminCustomerThreadsControllerCore extends AdminController 'filter_type' => 'int', ), 'subject' => array( - 'title' => $this->l('Subject'), + 'title' => $this->l('Title'), 'filter_key' => 'a!subject', 'tmpTableFilter' => true, - 'maxlength' => 40, + 'maxlength' => 30, 'optional' => true, 'visible_default' => true, ), @@ -142,25 +142,28 @@ class AdminCustomerThreadsControllerCore extends AdminController 'title' => $this->l('Employee'), 'filter_key' => 'employee', 'tmpTableFilter' => true, + 'optional' => true, + ), + 'last_employee' => array( + 'title' => $this->l('Last Reply by'), + 'filter_key' => 'employee', + 'tmpTableFilter' => true, + 'optional' => true, ), 'messages' => array( 'title' => $this->l('Messages'), 'filter_key' => 'messages', 'tmpTableFilter' => true, - 'maxlength' => 40, + 'maxlength' => 30, 'optional' => true, ), - 'private' => array( + 'has_private' => array( 'title' => $this->l('Has Private'), - 'type' => 'select', - 'filter_key' => 'private', + 'type' => 'bool', + 'havingFilter' => true, + 'filter_key' => 'has_private', 'align' => 'center', - 'cast' => 'intval', 'callback' => 'printOptinIcon', - 'list' => array( - '0' => $this->l('No'), - '1' => $this->l('Yes') - ) ), 'date_upd' => array( 'title' => $this->l('Last message'), @@ -223,11 +226,21 @@ class AdminCustomerThreadsControllerCore extends AdminController 'hint' => $this->l('Set Name as required while submitting message from the contact page.'), 'type' => 'bool' ), + 'PS_CUSTOMER_SERVICE_NAME_DISPLAY' => array( + 'title' => $this->l('Display Name field'), + 'hint' => $this->l('Display name field on contact page.'), + 'type' => 'bool', + ), 'PS_CUSTOMER_SERVICE_PHONE_REQUIRED' => array( 'title' => $this->l('Set Phone as required'), 'hint' => $this->l('Set Phone as required while submitting message from the contact page.'), 'type' => 'bool' ), + 'PS_CUSTOMER_SERVICE_PHONE_DISPLAY' => array( + 'title' => $this->l('Display Phone field'), + 'hint' => $this->l('Display phone field on contact page.'), + 'type' => 'bool', + ), 'PS_CUSTOMER_SERVICE_SIGNATURE' => array( 'title' => $this->l('Default message'), 'hint' => $this->l('Please fill out the message fields that appear by default when you answer a thread on the customer service page.'), @@ -343,7 +356,8 @@ class AdminCustomerThreadsControllerCore extends AdminController $this->addRowAction('delete'); $this->_select = ' - IF(a.`user_name`="", CONCAT(c.`firstname`," ",c.`lastname`), a.`user_name`) AS customer, cl.`name` as contact, l.`name` as language, group_concat(message) as messages, cm.private, + IF(a.`user_name`="", CONCAT(c.`firstname`," ",c.`lastname`), a.`user_name`) AS customer, cl.`name` as contact, l.`name` as language, group_concat(message) as messages, + cm.private, IF(COUNT(CASE WHEN cm.`private` = 1 THEN 1 END), 1, 0) AS `has_private`, ( SELECT IFNULL(CONCAT(LEFT(e.`firstname`, 1),". ",e.`lastname`), "--") FROM `'._DB_PREFIX_.'customer_message` cm2 @@ -352,9 +366,12 @@ class AdminCustomerThreadsControllerCore extends AdminController WHERE cm2.id_employee > 0 AND cm2.`id_customer_thread` = a.`id_customer_thread` ORDER BY cm2.`date_add` DESC LIMIT 1 - ) as employee'; + ) AS last_employee, + IFNULL(CONCAT(LEFT(emp.`firstname`, 1),". ",emp.`lastname`), "--") AS employee'; $this->_join = ' + LEFT JOIN `'._DB_PREFIX_.'employee` emp + ON emp.`id_employee` = a.`id_employee` LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = a.`id_customer` LEFT JOIN `'._DB_PREFIX_.'customer_message` cm @@ -386,11 +403,11 @@ class AdminCustomerThreadsControllerCore extends AdminController ), array( 'title' => $this->l('Total number of customer messages'), - 'val' => CustomerMessage::getTotalCustomerMessages('id_employee = 0'), + 'val' => CustomerMessage::getTotalCustomerMessages('ct.`id_employee` = 0'), ), array( 'title' => $this->l('Total number of employee messages'), - 'val' => CustomerMessage::getTotalCustomerMessages('id_employee != 0'), + 'val' => CustomerMessage::getTotalCustomerMessages('ct.`id_employee` != 0'), ), array( 'title' => $this->l('Unread threads'), @@ -432,6 +449,13 @@ class AdminCustomerThreadsControllerCore extends AdminController if (Tools::isSubmit('submitOptionsCustomerService')) { unset($this->fields_options['general']); $this->processUpdateOptions(); + if (Tools::getValue('PS_CUSTOMER_SERVICE_NAME_REQUIRED')) { + Configuration::updateValue('PS_CUSTOMER_SERVICE_NAME_DISPLAY', 1); + } + + if (Tools::getValue('PS_CUSTOMER_SERVICE_PHONE_REQUIRED')) { + Configuration::updateValue('PS_CUSTOMER_SERVICE_PHONE_DISPLAY', 1); + } } else if (Tools::isSubmit('submitOptionsIMAPConfig')) { unset($this->fields_options['contact']); $this->processUpdateOptions(); @@ -443,6 +467,7 @@ class AdminCustomerThreadsControllerCore extends AdminController } if ($id_customer_thread = (int)Tools::getValue('id_customer_thread')) { + $ct = new CustomerThread($id_customer_thread); if (($id_contact = (int)Tools::getValue('id_contact'))) { Db::getInstance()->execute(' UPDATE '._DB_PREFIX_.'customer_thread @@ -457,7 +482,7 @@ class AdminCustomerThreadsControllerCore extends AdminController WHERE id_customer_thread = '.(int)$id_customer_thread.' LIMIT 1 '); } - if (isset($_POST['id_employee_forward'])) { + if ($id_employee = (int) Tools::getValue('id_employee_forward')) { $messages = Db::getInstance()->getRow(' SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname @@ -471,7 +496,7 @@ class AdminCustomerThreadsControllerCore extends AdminController LEFT OUTER JOIN '._DB_PREFIX_.'customer c ON (c.email = ct.email) WHERE ct.id_customer_thread = '.(int)Tools::getValue('id_customer_thread').' - ORDER BY cm.date_add, cm.id_employee, cm.private DESC + ORDER BY cm.id_employee, cm.private, cm.date_add DESC '); $output = $this->displayMessage($messages, true, (int)Tools::getValue('id_employee_forward')); $cm = new CustomerMessage(); @@ -505,6 +530,8 @@ class AdminCustomerThreadsControllerCore extends AdminController $current_employee->firstname.' '.$current_employee->lastname, null, null, _PS_MAIL_DIR_, true) ) { + $ct->id_employee = $employee->id; + $ct->save(); $cm->id_employee = (int)$employee->id; $cm->private = 1; $cm->message = $this->l('Message forwarded to').' '.$employee->firstname.' '.$employee->lastname."\n".$this->l('Comment:').' '.$message; @@ -534,12 +561,13 @@ class AdminCustomerThreadsControllerCore extends AdminController } } if (Tools::isSubmit('submitReply') || Tools::isSubmit('submitReplyAndClose')) { - $ct = new CustomerThread($id_customer_thread); - ShopUrl::cacheMainDomainForShop((int)$ct->id_shop); $cm = new CustomerMessage(); $cm->id_employee = (int)$this->context->employee->id; + if (!$ct->id_employee) { + $ct->id_employee = $this->context->employee->id; + } $cm->id_customer_thread = $ct->id; $cm->ip_address = (int)ip2long(Tools::getRemoteAddr()); $cm->message = Tools::getValue('reply_message'); @@ -555,27 +583,7 @@ class AdminCustomerThreadsControllerCore extends AdminController $file_attachment['mime'] = $_FILES['joinFile']['type']; } $customer = new Customer($ct->id_customer); - if ($ct->id_order) { - $link = Tools::url( - $this->context->link->getPageLink('order-detail', true, (int)$ct->id_lang, null, false, $ct->id_shop), - 'id_order='.$ct->id_order - ); - } else { - $link = Tools::url( - $this->context->link->getPageLink('contact', true, (int)$ct->id_lang, null, false, $ct->id_shop), - 'token='.$ct->token - ); - } - $headingText = $this->l('Hi'); - if ($customer->id) { - $headingText .= ' '.$customer->firstname.' '.$customer->lastname; - } - $params = array( - '{reply}' => Tools::nl2br(Tools::getValue('reply_message')), - '{link}' => $link, - '{headingtext}' => $headingText - ); //#ct == id_customer_thread #tc == token of thread <== used in the synchronization imap $contact = new Contact((int)$ct->id_contact, (int)$ct->id_lang); @@ -587,15 +595,76 @@ class AdminCustomerThreadsControllerCore extends AdminController $from_email = null; } + if ($ct->id_order) { + $link = Tools::url( + $this->context->link->getPageLink('order-detail', true, (int)$ct->id_lang, null, false, $ct->id_shop), + 'id_order='.$ct->id_order + ); + $objOrder = new Order($ct->id_order); + $message = $cm->message; + if (Configuration::get('PS_MAIL_TYPE', null, null, $objOrder->id_shop) != Mail::TYPE_TEXT) { + $message = Tools::nl2br($cm->message); + } + + $objCustomer = new Customer($objOrder->id_customer); + $idShop = $objOrder->id_shop; + $params = array( + '{lastname}' => $objCustomer->lastname, + '{firstname}' => $objCustomer->firstname, + '{id_order}' => $objOrder->id, + '{order_name}' => $objOrder->getUniqReference(), + '{message}' => $message + ); + $toEmail = $objCustomer->email; + $toName = $objCustomer->firstname.' '.$objCustomer->lastname; + $title = Mail::l('New message regarding your booking', (int)$objOrder->id_lang); + $template = 'order_merchant_comment'; + $idLang = $objOrder->id_lang; + } else { + $link = Tools::url( + $this->context->link->getPageLink('contact', true, (int)$ct->id_lang, null, false, $ct->id_shop), + 'token='.$ct->token + ); + $headingText = $this->l('Hi'); + $idShop = $ct->id_shop; + $params = array( + '{reply}' => Tools::nl2br(Tools::getValue('reply_message')), + '{link}' => $link, + '{headingtext}' => $headingText, + ); + if (!empty(trim($ct->subject))) { + $params['{subject}'] = $this->l('Title : ').$ct->subject; + } + + $idLang = $ct->id_lang; + $toEmail = Tools::getValue('msg_email'); + $toName = null; + $template = 'reply_msg'; + $title = Mail::l('An answer to your message is available', $ct->id_lang); + if ($customer->id) { + $headingText .= ' '.$customer->firstname.' '.$customer->lastname; + } + } + if (Mail::Send( - (int)$ct->id_lang, - 'reply_msg', - sprintf(Mail::l('An answer to your message is available #ct%1$s #tc%2$s', $ct->id_lang), $ct->id, $ct->token), - $params, Tools::getValue('msg_email'), null, $from_email, $from_name, $file_attachment, null, - _PS_MAIL_DIR_, true, $ct->id_shop) - ) { + (int) $idLang, + $template, + $title, + $params, + $toEmail, + $toName, + $from_email, + $from_name, + $file_attachment, + null, + _PS_MAIL_DIR_, + true, + $idShop + )) { if (Tools::isSubmit('submitReplyAndClose')) { $ct->status = CustomerThread::QLO_CUSTOMER_THREAD_STATUS_CLOSED; + } else { + $ct->status = CustomerThread::QLO_CUSTOMER_THREAD_STATUS_OPEN; } $ct->update(); @@ -607,7 +676,10 @@ class AdminCustomerThreadsControllerCore extends AdminController $this->errors[] = Tools::displayError('An error occurred. Your message was not sent. Please contact your system administrator.'); } } else if (Tools::isSubmit('submitReplyAsPrivate')) { - $ct = new CustomerThread($id_customer_thread); + if (!$ct->id_employee) { + $ct->id_employee = $this->context->employee->id; + $ct->update(); + } ShopUrl::cacheMainDomainForShop((int)$ct->id_shop); $cm = new CustomerMessage(); $cm->id_employee = (int)$this->context->employee->id; @@ -622,8 +694,6 @@ class AdminCustomerThreadsControllerCore extends AdminController $this->errors[] = Tools::displayError('Some error occured while saving the message'); } } - - } return parent::postProcess(); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index e3d7a9050..c930d4ba9 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1424,6 +1424,10 @@ class AdminOrdersControllerCore extends AdminController $customer_thread = new CustomerThread(); $customer_thread->id_contact = 0; $customer_thread->id_customer = (int)$order->id_customer; + $customer_thread->user_name = $customer->firstname.' '.$customer->lastname; + $customer_thread->phone = $customer->phone; + $customer_thread->subject = $order->reference; + $customer_thread->id_employee = (int)$this->context->employee->id; $customer_thread->id_shop = (int)$this->context->shop->id; $customer_thread->id_order = (int)$order->id; $customer_thread->id_lang = (int)$this->context->language->id; @@ -1461,7 +1465,7 @@ class AdminOrdersControllerCore extends AdminController if (@Mail::Send( (int)$order->id_lang, 'order_merchant_comment', - Mail::l('New message regarding your order', (int)$order->id_lang), + Mail::l('New message regarding your booking', (int)$order->id_lang), $varsTpl, $customer->email, $customer->firstname.' '.$customer->lastname, diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php index b3b863326..329e71233 100644 --- a/controllers/front/ContactController.php +++ b/controllers/front/ContactController.php @@ -118,11 +118,7 @@ class ContactControllerCore extends FrontController if ($contact->customer_service) { if ((int)$id_customer_thread) { $ct = new CustomerThread($id_customer_thread); - $ct->status = CustomerThread::QLO_CUSTOMER_THREAD_STATUS_OPEN; - $ct->id_lang = (int)$this->context->language->id; - $ct->id_contact = (int)$id_contact; $ct->id_order = (int)$id_order; - $ct->update(); } else { $ct = new CustomerThread(); if (isset($customer->id)) { @@ -132,15 +128,15 @@ class ContactControllerCore extends FrontController $ct->phone = $phone; $ct->user_name = $userName; $ct->subject = $subject; - $ct->id_contact = (int)$id_contact; - $ct->id_lang = (int)$this->context->language->id; $ct->email = $from; - $ct->status = CustomerThread::QLO_CUSTOMER_THREAD_STATUS_OPEN; $ct->token = Tools::passwdGen(12); - $ct->add(); } - if ($ct->id) { + $ct->status = CustomerThread::QLO_CUSTOMER_THREAD_STATUS_OPEN; + $ct->id_lang = (int)$this->context->language->id; + $ct->id_contact = (int)$id_contact; + + if ($ct->save()) { $cm = new CustomerMessage(); $cm->id_customer_thread = $ct->id; $cm->message = $message; @@ -163,15 +159,16 @@ class ContactControllerCore extends FrontController if (!count($this->errors)) { $var_list = array( - '{order_name}' => '-', - '{attached_file}' => '-', - '{message}' => Tools::nl2br(stripslashes($message)), - '{email}' => $from, - '{product_name}' => '', - ); + '{order_name}' => '-', + '{attached_file}' => ' ', + '{message}' => Tools::nl2br(stripslashes($message)), + '{email}' => $from, + '{product_name}' => '', + '{subject}' => $ct->subject, + ); if (isset($file_attachment['name'])) { - $var_list['{attached_file}'] = $file_attachment['name']; + $var_list['{attached_file}'] = ''.$this->l('Attached file').':'.$file_attachment['name']; } $id_product = (int)Tools::getValue('id_product'); @@ -253,9 +250,13 @@ class ContactControllerCore extends FrontController $email = Tools::safeOutput(Tools::getValue('from', ((isset($this->context->cookie) && isset($this->context->cookie->email) && Validate::isEmail($this->context->cookie->email)) ? $this->context->cookie->email : ''))); + $customerName = isset($this->context->customer) ? $this->context->customer->firstname.' '.$this->context->customer->lastname : ''; + $customerPhone = isset($this->context->customer) ? $this->context->customer->phone: ''; $this->context->smarty->assign(array( 'errors' => $this->errors, 'email' => $email, + 'customerName' => $customerName, + 'customerPhone' => $customerPhone, 'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD'), 'max_upload_size' => (int)Tools::getMaxUploadSize() )); @@ -315,7 +316,9 @@ class ContactControllerCore extends FrontController 'message' => html_entity_decode(Tools::getValue('message')), 'contactKey' => $contactKey, 'contactNameRequired' => Configuration::get('PS_CUSTOMER_SERVICE_NAME_REQUIRED'), + 'displayContactName' => Configuration::get('PS_CUSTOMER_SERVICE_NAME_DISPLAY'), 'contactPhoneRequired' => Configuration::get('PS_CUSTOMER_SERVICE_PHONE_REQUIRED'), + 'displayContactPhone' => Configuration::get('PS_CUSTOMER_SERVICE_PHONE_DISPLAY'), 'allowContactSelection' => Configuration::get('PS_CUSTOMER_SERVICE_CONTACT_ALLOW') ) ); diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 892273c29..80e9a335d 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -460,7 +460,7 @@ class OrderDetailControllerCore extends FrontController 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) ? new State($addressDelivery->id_state) : false, 'is_guest' => false, - 'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false), + 'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), @@ -690,10 +690,14 @@ class OrderDetailControllerCore extends FrontController $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($this->context->customer->email, $order->id); $id_product = (int)Tools::getValue('id_product'); $cm = new CustomerMessage(); + $objCustomer = new Customer($order->id_customer); if (!$id_customer_thread) { $ct = new CustomerThread(); $ct->id_contact = 0; $ct->id_customer = (int)$order->id_customer; + $ct->user_name = $objCustomer->firstname.' '.$objCustomer->lastname; + $ct->subject = $order->reference; + $ct->phone = $objCustomer->phone; $ct->id_shop = (int)$this->context->shop->id; $ct->id_order = (int)$order->id; $ct->id_lang = (int)$this->context->language->id; @@ -763,7 +767,7 @@ class OrderDetailControllerCore extends FrontController // send message html in json $response['status'] = true; - $message = CustomerMessage::getMessagesByOrderId($order->id, false)[0]; + $message = CustomerMessage::getMessagesByOrderId($order->id)[0]; $this->context->smarty->assign(array('message' => $message)); $response['message_html'] = $this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/order-message.tpl'); } else { diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 5f1457ee9..6f6769302 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -658,6 +658,7 @@ CREATE TABLE `PREFIX_customer_thread` ( `id_lang` int(10) unsigned NOT NULL, `id_contact` int(10) unsigned NOT NULL, `id_customer` int(10) unsigned DEFAULT NULL, + `id_employee` int(10) unsigned DEFAULT NULL, `id_order` int(10) unsigned DEFAULT NULL, `user_name` VARCHAR(128) DEFAULT NULL, `phone` VARCHAR(32) DEFAULT NULL, diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index e111894ed..2696980f6 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -952,9 +952,15 @@ 1 + + + 1 1 + + + 1 1 diff --git a/js/admin/customer_thread.js b/js/admin/customer_thread.js index bee35d067..94aeea291 100644 --- a/js/admin/customer_thread.js +++ b/js/admin/customer_thread.js @@ -22,6 +22,14 @@ $(document).ready(function() { $('[name="PS_CUSTOMER_SERVICE_EMAIL_MESSAGE"]').closest('.form-group').hide(); } + if ($('#PS_CUSTOMER_SERVICE_NAME_REQUIRED_on').prop('checked')) { + $('[name="PS_CUSTOMER_SERVICE_NAME_DISPLAY"]').closest('.form-group').hide(); + } + + if ($('#PS_CUSTOMER_SERVICE_PHONE_REQUIRED_on').prop('checked')) { + $('[name="PS_CUSTOMER_SERVICE_PHONE_DISPLAY"]').closest('.form-group').hide(); + } + $(document).on('change', '[name="PS_CUSTOMER_SERVICE_CONTACT_ALLOW"]', function() { if ($('#PS_CUSTOMER_SERVICE_CONTACT_ALLOW_on').prop('checked')) { $('[name="PS_CUSTOMER_SERVICE_EMAIL_MESSAGE"]').closest('.form-group').hide(); @@ -29,4 +37,23 @@ $(document).ready(function() { $('[name="PS_CUSTOMER_SERVICE_EMAIL_MESSAGE"]').closest('.form-group').show(); } }); + + $(document).on('change', '[name="PS_CUSTOMER_SERVICE_NAME_REQUIRED"]', function() { + if ($('#PS_CUSTOMER_SERVICE_NAME_REQUIRED_on').prop('checked')) { + $('[name="PS_CUSTOMER_SERVICE_NAME_DISPLAY"]').closest('.form-group').hide(); + $('#PS_CUSTOMER_SERVICE_NAME_DISPLAY_on').prop('checked', true); + } else { + $('[name="PS_CUSTOMER_SERVICE_NAME_DISPLAY"]').closest('.form-group').show(); + } + }); + + $(document).on('change', '[name="PS_CUSTOMER_SERVICE_PHONE_REQUIRED"]', function() { + if ($('#PS_CUSTOMER_SERVICE_PHONE_REQUIRED_on').prop('checked')) { + $('[name="PS_CUSTOMER_SERVICE_PHONE_DISPLAY"]').closest('.form-group').hide(); + $('#PS_CUSTOMER_SERVICE_PHONE_DISPLAY_on').prop('checked', true); + } else { + $('[name="PS_CUSTOMER_SERVICE_PHONE_DISPLAY"]').closest('.form-group').show(); + } + }); + }); diff --git a/mails/en/contact.html b/mails/en/contact.html index 3ebbf35d5..c9c93ad62 100644 --- a/mails/en/contact.html +++ b/mails/en/contact.html @@ -86,6 +86,7 @@ Customer e-mail address:
{email}

+ Title: {subject}

Customer message: {message}

Attached file: {attached_file} diff --git a/mails/en/contact.txt b/mails/en/contact.txt index 152a1581c..ccd9a4132 100644 --- a/mails/en/contact.txt +++ b/mails/en/contact.txt @@ -1,16 +1,16 @@ -[/{shop_url}] +[/{shop_url}] -Message from a {shop_name} customer +Message from a {shop_name} customer CUSTOMER E-MAIL ADDRESS: {email} +TITLE : {subject} + CUSTOMER MESSAGE: {message} -ORDER ID: {order_name} - -ATTACHED FILE: {attached_file} +ATTACHED FILE: {attached_file} {shop_name} [/{shop_url}] powered by Webkul(tm) -[https://webkul.com] +[https://webkul.com] diff --git a/mails/en/order_customer_comment.html b/mails/en/order_customer_comment.html index 83cb0223e..42df13834 100644 --- a/mails/en/order_customer_comment.html +++ b/mails/en/order_customer_comment.html @@ -4,51 +4,51 @@ Message from {shop_name} - - - @@ -87,7 +87,7 @@

Message from a customer

- You have received a new message regarding order with the reference {order_name}.

+ You have received a new message regarding booking with the reference {order_name}.

Customer: {firstname} {lastname} ({email})

{message}
diff --git a/mails/en/order_customer_comment.txt b/mails/en/order_customer_comment.txt index d5055db73..2c2e715b1 100644 --- a/mails/en/order_customer_comment.txt +++ b/mails/en/order_customer_comment.txt @@ -1,15 +1,15 @@ -[/{shop_url}] +[/{shop_url}] -Hi {firstname} {lastname}, +Hi {firstname} {lastname}, -You have received a new message regarding order with the reference +You have received a new message regarding booking with the reference {order_name}. CUSTOMER: {firstname} {lastname} ({email}) -{message} +{message} {shop_name} [/{shop_url}] powered by Webkul(tm) -[https://webkul.com] +[https://webkul.com] diff --git a/mails/en/reply_msg.html b/mails/en/reply_msg.html index c71767da6..98616b76a 100644 --- a/mails/en/reply_msg.html +++ b/mails/en/reply_msg.html @@ -71,6 +71,11 @@ {headingtext} + + + Title: {subject} + +   diff --git a/mails/en/reply_msg.txt b/mails/en/reply_msg.txt index c654fa2df..0953fc4e9 100644 --- a/mails/en/reply_msg.txt +++ b/mails/en/reply_msg.txt @@ -3,6 +3,8 @@ {headingtext}, +{subject} + {reply} Please do not reply directly to this email, we will not receive it. diff --git a/themes/hotel-reservation-theme/contact-form.tpl b/themes/hotel-reservation-theme/contact-form.tpl index 63fd52fa9..62ee452f5 100644 --- a/themes/hotel-reservation-theme/contact-form.tpl +++ b/themes/hotel-reservation-theme/contact-form.tpl @@ -75,14 +75,16 @@ {else}
{/if} + {if isset($displayContactName) && $displayContactName}
- +
+ {/if}
+ {if isset($displayContactPhone) && $displayContactPhone}
- +
+ {/if}
@@ -150,9 +154,6 @@
-
- {l s='* Required fields'} -
{if $fileupload == 1}
@@ -164,6 +165,9 @@
{/if} +
+ {l s='* Required fields'} +
{hook h='displayGDPRConsent' moduleName='contactform'} {hook h='displayContactFormFieldsAfter'}