Merge branch 'ticket-13166-ReturnProcess' into develop
This commit is contained in:
commit
13f963acaa
@ -57,6 +57,63 @@ class AdminAntReturnprocess extends AdminTab
|
||||
} else {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('No order return ID.'));
|
||||
}
|
||||
} elseif (Tools::isSubmit('submitReply')) {
|
||||
if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return))
|
||||
{
|
||||
if (($id_customer_thread = (int)(Tools::getValue('id_customer_thread'))) AND Validate::isUnsignedId($id_customer_thread)) {
|
||||
$ct = new CustomerThread($id_customer_thread);
|
||||
$cm = new CustomerMessage();
|
||||
$cm->id_employee = (int)$cookie->id_employee;
|
||||
$cm->id_customer_thread = $ct->id;
|
||||
$cm->message = Tools::htmlentitiesutf8(nl2br2(Tools::getValue('reply_message')));
|
||||
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
|
||||
|
||||
if (isset($_FILES) AND !empty($_FILES['joinFile']['name']) AND $_FILES['joinFile']['error'] != 0) {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred with the file upload.'));
|
||||
} elseif ($cm->add()) {
|
||||
$fileAttachment = NULL;
|
||||
if (!empty($_FILES['joinFile']['name']))
|
||||
{
|
||||
$cm->file_name = $_FILES['joinFile']['name'];
|
||||
$fileAttachment['content'] = file_get_contents($_FILES['joinFile']['tmp_name']);
|
||||
$fileAttachment['name'] = $_FILES['joinFile']['name'];
|
||||
$fileAttachment['mime'] = $_FILES['joinFile']['type'];
|
||||
}
|
||||
if($ct->id_contact == 9 || $ct->id_contact == 1) {
|
||||
$id_reason = Db::getInstance()->getValue('
|
||||
SELECT sr.`id_reason`
|
||||
FROM `'._DB_PREFIX_.'support_reason` sr
|
||||
LEFT JOIN `'._DB_PREFIX_.'support_reason_customerthread` src ON (src.id_reason = sr.id_reason)
|
||||
WHERE `id_customer_thread` = '.(int)($ct->id)
|
||||
);
|
||||
$link_reply = ($ct->id_lang == 3 ? str_replace('com','es',Tools::getShopDomain(true).__PS_BASE_URI__):Tools::getShopDomain(true).__PS_BASE_URI__).'modules/ant_support_form/support.php?id_customer_thread='.(int)($ct->id).'&token='.$ct->token.(($ct->id_contact == 9 || $ct->id_contact == 1)?'&id_contact='.$ct->id_contact : '').((isset($id_reason) && $id_reason)?'&id_reason='.(int)$id_reason : '');
|
||||
} else {
|
||||
$link_reply = $link->getPageLink('contact-form.php', true).'?id_customer_thread='.(int)($ct->id).'&token='.$ct->token;
|
||||
if($ct->id_lang == 3) {
|
||||
$link_reply = str_replace('com','es',$link_reply);
|
||||
}
|
||||
}
|
||||
$params = array(
|
||||
'{reply}' => nl2br2(Tools::getValue('reply_message')),
|
||||
'{link}' => $link_reply);
|
||||
if (Mail::Send($ct->id_lang, 'reply_msg', Mail::l('An answer to your message is available'),
|
||||
$params, Tools::getValue('msg_email'), NULL, NULL, NULL, $fileAttachment, NULL,
|
||||
_PS_MAIL_DIR_, true))
|
||||
{
|
||||
$ct->status = 'closed';
|
||||
$ct->update();
|
||||
$cm->update();
|
||||
}
|
||||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&conf=4&token='.$this->token);
|
||||
} else {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred, your message was not sent. Please contact your system administrator.'));
|
||||
}
|
||||
} else {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('No conversation ID.'));
|
||||
}
|
||||
} else {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('No order return ID.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,6 +192,16 @@ class AdminAntReturnprocess extends AdminTab
|
||||
');
|
||||
if($query_thread) {
|
||||
$thread = new CustomerThread((int)$query_thread);
|
||||
$last_message = 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
|
||||
FROM '._DB_PREFIX_.'customer_thread ct
|
||||
LEFT JOIN '._DB_PREFIX_.'customer_message cm ON (ct.id_customer_thread = cm.id_customer_thread)
|
||||
LEFT JOIN '._DB_PREFIX_.'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = '.(int)$cookie->id_lang.')
|
||||
LEFT JOIN '._DB_PREFIX_.'employee e ON e.id_employee = cm.id_employee
|
||||
LEFT JOIN '._DB_PREFIX_.'customer c ON (IFNULL(ct.id_customer, ct.email) = IFNULL(c.id_customer, c.email))
|
||||
WHERE ct.id_customer_thread = '.(int)($thread->id).'
|
||||
ORDER BY cm.date_add DESC'
|
||||
);
|
||||
}
|
||||
|
||||
$returnProducts = OrderReturn::getOrdersReturnProducts($orderReturn->id, $order);
|
||||
@ -358,7 +425,7 @@ class AdminAntReturnprocess extends AdminTab
|
||||
AND pl.`id_lang` = 2'
|
||||
);
|
||||
if($products && !empty($products)) {
|
||||
$html .='<h5>Produit(s) Concerné(s) :</h5>';
|
||||
$html .='<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Produit(s) Concerné(s)</h5>';
|
||||
foreach ($products as $product) {
|
||||
$img_path = '';
|
||||
$img = Db::getInstance()->getRow('
|
||||
@ -378,7 +445,57 @@ class AdminAntReturnprocess extends AdminTab
|
||||
</a>';
|
||||
}
|
||||
}
|
||||
$html .='';
|
||||
if($last_message){
|
||||
$html .='<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Dernier Message</h5>';
|
||||
$last_message['message'] = preg_replace('/(https?:\/\/[a-z0-9#%&_=\(\)\.\? \+\-@\/]{6,1000})([\s\n<])/Uui', '<a href="\1">\1</a>\2', html_entity_decode($last_message['message'], ENT_NOQUOTES, 'UTF-8'));
|
||||
|
||||
if(!empty($last_message['employee_name'])) {
|
||||
$html .='
|
||||
<div>
|
||||
<p class="text-center"><span class="anticon anticon-user-tie"></span> Bébé Boutik - ('.Tools::displayDate($last_message['date_add'], (int)($cookie->id_lang), true).')</p>
|
||||
<p style="padding:5px 20px;background:#efefef;">
|
||||
"'.$last_message['message'].'"
|
||||
</p>
|
||||
</div>';
|
||||
} else {
|
||||
$html .='
|
||||
<div>
|
||||
<p class="text-center"><span class="anticon anticon-user"></span> '.$customer->firstname.' '.$customer->lastname.' - ('.Tools::displayDate($last_message['date_add'], (int)($cookie->id_lang), true).')</p>
|
||||
<p style="padding:5px 20px;background:#efefef;">
|
||||
"'.$last_message['message'].'"
|
||||
</p>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$orderMessages = OrderMessage::getOrderMessages((int)($last_message['id_lang']));
|
||||
$html .='
|
||||
<div>
|
||||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Envoyer un message</h5>
|
||||
<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<select class="form-control" name="order_message" id="order_message" onchange="savOverwriteMessage(this, \''.$this->l('Do you want to overwrite your existing message?').'\', \''.(int)($last_message['id_customer_message']).'\')">
|
||||
<option value="0" selected="selected">-- '.$this->l('Choose a standard message').' --</option>';
|
||||
foreach ($orderMessages AS $orderMessage) {
|
||||
$html .= '<option value="'.htmlentities($orderMessage['message'], ENT_COMPAT, 'UTF-8').'">'.$orderMessage['name'].'</option>';
|
||||
}
|
||||
$html .= '
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="file" name="joinFile"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<textarea rows="5" class="form-control" id="txt_msg_'.(int)($last_message['id_customer_message']).'" name="reply_message">'.str_replace('\r\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', $last_message['id_lang'])).'</textarea>
|
||||
</div>
|
||||
<div style="text-align: right;">
|
||||
<input type="hidden" name="id_customer_thread" value="'.(int)($last_message['id_customer_thread']).'" />
|
||||
<input type="hidden" name="msg_email" value="'.$last_message['email'].'" />
|
||||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||||
<input type="submit" class="btn btn-primary" name="submitReply" value="'.$this->l('Envoyer').'" style="margin-top:20px;" />
|
||||
</div>
|
||||
</form>
|
||||
</div>';
|
||||
}
|
||||
} else {
|
||||
$html .='<p>Pas de conversation en rapport avec cette commande !</p>';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user