2280 lines
152 KiB
PHP
2280 lines
152 KiB
PHP
<?php
|
||
if(!defined('_PS_VERSION_')) {
|
||
exit;
|
||
}
|
||
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
|
||
|
||
global $logistics_carriers;
|
||
foreach(array_map(function($value) {
|
||
return str_replace('.', '', $value);
|
||
}, array_diff(scandir(dirname(__FILE__).'/carriers'), array('.', '..'))) as $lg) {
|
||
if(is_dir(dirname(__FILE__).'/carriers/'.$lg)) {
|
||
include dirname(__FILE__).'/carriers/'.$lg.'/'.$lg.'.php';
|
||
$name = ucfirst($lg).'Carrier';
|
||
$logistics_carriers[$lg] = new $name();
|
||
}
|
||
}
|
||
|
||
class AdminAntReturnprocess extends AdminTab
|
||
{
|
||
private function stripaccents($str) {
|
||
return preg_replace(
|
||
'~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);~i',
|
||
'$1',
|
||
htmlentities($str, ENT_NOQUOTES, 'UTF-8')
|
||
);
|
||
}
|
||
|
||
private function isoreplace($str) {
|
||
// ISO/CEI 646
|
||
return str_replace(array(
|
||
'Ç', 'ü', 'é', 'â', 'ä', 'à',
|
||
'å', 'ç', 'ê', 'ë', 'è', 'ï',
|
||
'î', 'ì', 'Ä', 'Å', 'É', 'æ',
|
||
'Æ', 'ô', 'ö', 'ò', 'û', 'ù',
|
||
'ÿ', 'Ö', 'Ü', '¢', '£', '¥',
|
||
'₧', 'ƒ', 'á', 'í', 'ó', 'ú',
|
||
'ñ', 'Ñ', 'ª', 'º', '¿', '⌐',
|
||
'¬', '½', '¼', '¡', '«', '»',
|
||
'░', '▒', '▓', '│', '┤', '╡',
|
||
'╢', '╖', '╕', '╣', '║', '╗',
|
||
'╝', '╜', '╛', '┐', '└', '┴',
|
||
'┬', '├', '─', '┼', '╞', '╟',
|
||
'╚', '╔', '╩', '╦', '╠', '═',
|
||
'╬', '╧', '╨', '╤', '╥', '╙',
|
||
'╘', '╒', '╓', '╫', '╪', '┘',
|
||
'┌', '█', '▄', '▌', '▐', '▀',
|
||
'α', 'ß', 'Γ', 'π', 'Σ', 'σ',
|
||
'µ', 'τ', 'Φ', 'Θ', 'Ω', 'δ',
|
||
'∞', 'φ', 'ε', '∩', '≡', '±',
|
||
'≥', '≤', '⌠', '⌡', '÷', '≈',
|
||
'°', '∙', '·', '√', 'ⁿ', '²',
|
||
'■',
|
||
), array(
|
||
chr(128), chr(129), chr(130), chr(131), chr(132), chr(133),
|
||
chr(134), chr(135), chr(136), chr(137), chr(138), chr(139),
|
||
chr(140), chr(141), chr(142), chr(143), chr(144), chr(145),
|
||
chr(146), chr(147), chr(148), chr(149), chr(150), chr(151),
|
||
chr(152), chr(153), chr(154), chr(155), chr(156), chr(157),
|
||
chr(158), chr(159), chr(160), chr(161), chr(162), chr(163),
|
||
chr(164), chr(165), chr(166), chr(167), chr(165), chr(166),
|
||
chr(167), chr(168), chr(169), chr(170), chr(171), chr(172),
|
||
chr(173), chr(174), chr(175), chr(176), chr(177), chr(178),
|
||
chr(179), chr(180), chr(181), chr(182), chr(183), chr(184),
|
||
chr(185), chr(186), chr(187), chr(188), chr(189), chr(190),
|
||
chr(191), chr(192), chr(193), chr(194), chr(195), chr(196),
|
||
chr(197), chr(198), chr(199), chr(200), chr(201), chr(202),
|
||
chr(203), chr(204), chr(205), chr(206), chr(207), chr(208),
|
||
chr(209), chr(210), chr(211), chr(209), chr(210), chr(211),
|
||
chr(212), chr(213), chr(214), chr(215), chr(216), chr(217),
|
||
chr(218), chr(219), chr(220), chr(221), chr(222), chr(223),
|
||
chr(224), chr(225), chr(226), chr(227), chr(228), chr(229),
|
||
chr(230), chr(231), chr(232), chr(233), chr(234), chr(235),
|
||
chr(236), chr(237), chr(238), chr(239), chr(240), chr(241),
|
||
chr(242), chr(243), chr(244), chr(245), chr(246), chr(247),
|
||
chr(248), chr(249), chr(250), chr(251), chr(252), chr(253),
|
||
chr(254),
|
||
), $str);
|
||
}
|
||
|
||
private function printLabel($data) {
|
||
global $cookie;
|
||
|
||
//require dirname(__FILE__).'/libs/predis/autoload.php'; // Conflicts with Prestashop autoload
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/OptionInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/AbstractOption.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/PrefixableCommandInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/CommandInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/AbstractCommand.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/PrefixableCommand.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/PubSubPublish.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/SingleConnectionInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/AbstractConnection.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/StreamConnection.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionParametersInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionParameters.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionFactoryInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionFactory.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Profile/ServerProfileInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Profile/ServerProfile.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Profile/ServerVersion26.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientCluster.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientPrefix.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientExceptions.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientReplication.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientConnectionFactory.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientProfile.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientOptionsInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientOptions.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/BasicClientInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/ClientInterface.php';
|
||
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Client.php';
|
||
|
||
$redis = new Predis\Client();
|
||
|
||
$redis->publish(
|
||
Configuration::get('LOGISTICS_QUEUE_'.(int) $cookie->id_employee),
|
||
json_encode(array('data' => base64_encode(
|
||
chr(2).'n'."\n" // Inch mode
|
||
.chr(2).'O0100'."\n" // Start position
|
||
.chr(2).'L'."\n"
|
||
.'C0000'."\n"
|
||
.'D11'."\n"
|
||
.chr(2).'L'."\n"
|
||
.$this->isoreplace($data)
|
||
.'Q0001'."\n" // Number of labels to print
|
||
.'E'."\n" // End
|
||
)))
|
||
);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
public function postProcess()
|
||
{
|
||
global $currentIndex, $cookie, $logistics_carriers;;
|
||
|
||
if (Tools::isSubmit('deleteorder_return_detail'))
|
||
{
|
||
if (($id_order_detail = (int)(Tools::getValue('id_order_detail'))) AND Validate::isUnsignedId($id_order_detail)) {
|
||
if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return)) {
|
||
$orderReturn = new OrderReturn($id_order_return);
|
||
if (!Validate::isLoadedObject($orderReturn)) {
|
||
die(Tools::displayError());
|
||
}
|
||
|
||
if ((int)($orderReturn->countProduct()) > 1) {
|
||
if (OrderReturn::deleteOrderReturnDetail($id_order_return, $id_order_detail, (int)(Tools::getValue('id_customization', 0)))){
|
||
Tools::redirectAdmin($currentIndex.'&conf=4token='.$this->token);
|
||
} else {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred while deleting an order return detail.'));
|
||
}
|
||
} else {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('You need at least one product.'));
|
||
}
|
||
} else {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('The order return is invalid.'));
|
||
}
|
||
} else {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('The order return detail is invalid.'));
|
||
}
|
||
} elseif (Tools::isSubmit('submitAddorder_return')) {
|
||
if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return))
|
||
{
|
||
$orderReturn = new OrderReturn($id_order_return);
|
||
$order = new Order($orderReturn->id_order);
|
||
$customer = new Customer($orderReturn->id_customer);
|
||
$orderReturn->state = (int)(Tools::getValue('state'));
|
||
if ($orderReturn->save())
|
||
{
|
||
$orderReturnState = new OrderReturnState($orderReturn->state);
|
||
Db::getInstance()->ExecuteS('
|
||
INSERT INTO `'._DB_PREFIX_.'order_return_history`
|
||
VALUES (
|
||
DEFAULT,
|
||
'.(int) $cookie->id_employee.',
|
||
'.(int) $orderReturn->id.',
|
||
'.(int) $orderReturn->state.',
|
||
NOW()
|
||
)
|
||
');
|
||
$vars = array(
|
||
'{lastname}' => $customer->lastname,
|
||
'{firstname}' => $customer->firstname,
|
||
'{id_order_return}' => $id_order_return,
|
||
'{state_order_return}' => (isset($orderReturnState->name[(int)$order->id_lang]) ? $orderReturnState->name[(int)$order->id_lang] : $orderReturnState->name[(int)Configuration::get('PS_LANG_DEFAULT')]));
|
||
Mail::Send((int)$order->id_lang, 'order_return_state', Mail::l('Your order return state has changed', (int)$order->id_lang),
|
||
$vars, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
|
||
NULL, _PS_MAIL_DIR_, true);
|
||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&ok=2&token='.$this->token);
|
||
}
|
||
} 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&ok=3&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.'));
|
||
}
|
||
} elseif(Tools::isSubmit('submitOrderMessage')){
|
||
if (!($id_order = (int)(Tools::getValue('id_order'))) OR !($id_customer = (int)(Tools::getValue('id_customer')))) {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred before sending message'));
|
||
return;
|
||
} elseif (!Tools::getValue('message')) {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('Message cannot be blank'));
|
||
return;
|
||
} else {
|
||
/* Get message rules and and check fields validity */
|
||
$rules = call_user_func(array('Message', 'getValidationRules'), 'Message');
|
||
foreach ($rules['required'] AS $field) {
|
||
if (($value = Tools::getValue($field)) == false AND (string)$value != '0') {
|
||
if (!Tools::getValue('id_'.$this->table) OR $field != 'passwd') {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is required.'));
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
foreach ($rules['size'] AS $field => $maxLength) {
|
||
if (Tools::getValue($field) AND Tools::strlen(Tools::getValue($field)) > $maxLength) {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is too long.').' ('.$maxLength.' '.Tools::displayError('chars max').')');
|
||
return;
|
||
}
|
||
}
|
||
foreach ($rules['validate'] AS $field => $function) {
|
||
if (Tools::getValue($field)) {
|
||
if (!Validate::$function(htmlentities(Tools::getValue($field), ENT_COMPAT, 'UTF-8'))) {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is invalid.'));
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
$message = new Message();
|
||
$message->id_employee = (int)($cookie->id_employee);
|
||
$message->message = htmlentities(Tools::getValue('message'), ENT_COMPAT, 'UTF-8');
|
||
$message->id_order = $id_order;
|
||
$message->private = Tools::getValue('visibility');
|
||
if (!$message->add()) {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred while sending message.'));
|
||
return;
|
||
} elseif ($message->private) {
|
||
HelperFormBootstrap::displaySuccess('Message bien envoyé');
|
||
return;
|
||
} elseif (Validate::isLoadedObject($customer = new Customer($id_customer))) {
|
||
$order = new Order((int)($message->id_order));
|
||
if (Validate::isLoadedObject($order))
|
||
{
|
||
$varsTpl = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order}' => $message->id_order, '{message}' => (Configuration::get('PS_MAIL_TYPE') == 2 ? $message->message : nl2br2($message->message)));
|
||
if (@Mail::Send((int)($order->id_lang), 'order_merchant_comment', Mail::l('New message regarding your order'), $varsTpl, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL, _PS_MAIL_DIR_, true)){
|
||
HelperFormBootstrap::displaySuccess('Message bien envoyé');
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
HelperFormBootstrap::displayErrors('Une erreur est survenue !');
|
||
return;
|
||
}
|
||
} elseif(Tools::getValue('send_return_instruction') && Tools::getValue('id_order_return')) {
|
||
$id_order = (int) Tools::getValue('id_order');
|
||
$id_order_return = (int) Tools::getValue('id_order_return');
|
||
if(Validate::isLoadedObject($order = new Order($id_order))) {
|
||
$customer = new Customer($order->id_customer);
|
||
$return_link = Db::getInstance()->getRow('
|
||
SELECT `return_number`, `link`
|
||
FROM `'._DB_PREFIX_.'order_return_link`
|
||
WHERE `id_order_return` = '.(int) $id_order_return.'
|
||
');
|
||
$products = Db::getInstance()->ExecuteS('
|
||
SELECT `id_order_detail`, `product_quantity`
|
||
FROM `'._DB_PREFIX_.'order_return_detail`
|
||
WHERE `id_order_return` = '.(int) $id_order_return.'
|
||
');
|
||
$product_list = '<ul>';
|
||
$product_list_txt = array();
|
||
foreach($products as $key => $product){
|
||
$product_name = Db::getInstance()->getValue('
|
||
SELECT `product_name`
|
||
FROM `'._DB_PREFIX_.'order_detail`
|
||
WHERE `id_order_detail` = '.(int) $product['id_order_detail'].'
|
||
');
|
||
$product_list_txt[] = (int) $product['product_quantity'].' x '.$product_name;
|
||
$product_list .= '<li>'.(int) $product['product_quantity'].' x '.htmlentities($product_name).'</li>';
|
||
}
|
||
$product_list .= '</ul>';
|
||
Mail::Send(
|
||
intval($order->id_lang),
|
||
'order_return_2',
|
||
$subject[(int) $order->id_lang],
|
||
array(
|
||
'{id_order}' => $order->id,
|
||
'{return_link}' => $return_link['link'],
|
||
'{product_list}' => $product_list,
|
||
'{product_list_txt}' => implode("\r\n", $product_list_txt),
|
||
),
|
||
$customer->email,
|
||
$customer->firstname.' '.$customer->lastname
|
||
);
|
||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&ok=4&token='.$this->token);
|
||
} else {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('Order ID missing.'));
|
||
}
|
||
} elseif (Tools::isSubmit('submitOrderState') && Tools::getValue('id_order_return') && ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order))) {
|
||
|
||
$id_order_return = (int) Tools::getValue('id_order_return');
|
||
if (!$newOrderStatusId = (int)(Tools::getValue('id_order_state'))) {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('Invalid new order status'));
|
||
} else {
|
||
$history = new OrderHistory();
|
||
$history->id_order = (int)$id_order;
|
||
$history->id_employee = (int)($cookie->id_employee);
|
||
$history->changeIdOrderState((int)($newOrderStatusId), (int)($id_order));
|
||
$order = new Order((int)$order->id);
|
||
$carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang));
|
||
|
||
$templateVars = array();
|
||
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') AND $order->shipping_number) {
|
||
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
|
||
} elseif ($history->id_order_state == Configuration::get('PS_OS_CHEQUE')) {
|
||
$templateVars = array(
|
||
'{cheque_name}' => (Configuration::get('CHEQUE_NAME') ? Configuration::get('CHEQUE_NAME') : ''),
|
||
'{cheque_address_html}' => (Configuration::get('CHEQUE_ADDRESS') ? nl2br(Configuration::get('CHEQUE_ADDRESS')) : ''));
|
||
} elseif ($history->id_order_state == Configuration::get('PS_OS_BANKWIRE')) {
|
||
$templateVars = array(
|
||
'{bankwire_owner}' => (Configuration::get('BANK_WIRE_OWNER') ? Configuration::get('BANK_WIRE_OWNER') : ''),
|
||
'{bankwire_details}' => (Configuration::get('BANK_WIRE_DETAILS') ? nl2br(Configuration::get('BANK_WIRE_DETAILS')) : ''),
|
||
'{bankwire_address}' => (Configuration::get('BANK_WIRE_ADDRESS') ? nl2br(Configuration::get('BANK_WIRE_ADDRESS')) : ''));
|
||
}
|
||
|
||
if (Tools::getValue('noSendMail')) {
|
||
if ($history->add()) {
|
||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&ok=5&token='.$this->token);
|
||
}
|
||
} else {
|
||
if ($history->addWithemail(true, $templateVars)) {
|
||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&ok=5&token='.$this->token);
|
||
}
|
||
}
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred while changing the status or was unable to send e-mail to the customer.'));
|
||
}
|
||
} elseif(Tools::isSubmit('submitPayPalRefund') && Tools::getValue('id_order_return') && ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order))) {
|
||
$paypal = new Paypal();
|
||
if(!$paypal->generateTotalRefund($id_order)){
|
||
HelperFormBootstrap::displayErrors('Le remboursement n\'a pu avoir lieu');
|
||
return;
|
||
}
|
||
} elseif(Tools::isSubmit('submitCancelProduct') && Tools::getValue('id_order_return') && ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order))) {
|
||
$_POST['generateCreditSlip'] = 1;
|
||
$customer = new Customer($order->id_customer);
|
||
|
||
$productList = Tools::getValue('cancelQuantity');
|
||
$id_order_details = array();
|
||
$refund_quantities = array();
|
||
foreach ($productList as $id_order_detail => $qty) {
|
||
if((int)$qty ==0) {
|
||
unset($productList[$id_order_detail]);
|
||
}
|
||
$id_order_details[$id_order_detail] = $id_order_detail;
|
||
$refund_quantities[$id_order_detail] = $qty;
|
||
}
|
||
$errors = 0;
|
||
|
||
$id_cart = Cart::getCartIdByOrderId($order->id);
|
||
foreach ($productList AS $id_order_detail => $qty)
|
||
{
|
||
$qtyCancelProduct = abs($qty);
|
||
if (!$qtyCancelProduct) {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('No quantity selected for product.'));
|
||
$errors++;
|
||
}
|
||
|
||
// check actionable quantity
|
||
$order_detail = new OrderDetail($id_order_detail);
|
||
$customization_quantity = 0;
|
||
if (array_key_exists($order_detail->product_id, $customization_quantities) && array_key_exists($order_detail->product_attribute_id, $customization_quantities[$order_detail->product_id])) {
|
||
$customization_quantity = (int) $customization_quantities[$order_detail->product_id][$order_detail->product_attribute_id];
|
||
}
|
||
|
||
if (($order_detail->product_quantity - $customization_quantity - $order_detail->product_quantity_refunded - $order_detail->product_quantity_return) < $qtyCancelProduct) {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('Invalid quantity selected for product.'));
|
||
$errors++;
|
||
}
|
||
}
|
||
if ($errors == 0 AND $productList) {
|
||
foreach ($productList AS $id_order_detail => $qty) {
|
||
$qtyCancelProduct = abs($qty);
|
||
$orderDetail = new OrderDetail((int)($id_order_detail));
|
||
|
||
//@Addition Antadis - prevent reinjection when the product is sent by Philea
|
||
$is_philea = DB::getInstance()->getValue('
|
||
SELECT p.`id_sale`
|
||
FROM `'._DB_PREFIX_.'philea_sync` p
|
||
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` ps ON (ps.`id_sale` = p.`id_sale`)
|
||
WHERE ps.`id_product`='.$orderDetail->product_id
|
||
);
|
||
// @Addition Antadis - prevent reinjection when the product is in Braderie
|
||
$is_braderie = (int)DB::getInstance()->getValue('
|
||
SELECT p.`braderie`
|
||
FROM `'._DB_PREFIX_.'privatesale` p
|
||
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` ps ON (ps.`id_sale` = p.`id_sale`)
|
||
WHERE ps.`id_product`='.$orderDetail->product_id
|
||
);
|
||
// $is_philea = false; // dev
|
||
// $is_braderie = false; // dev
|
||
// Reinject product
|
||
if (
|
||
!$order->hasBeenDelivered()
|
||
OR ($order->hasBeenDelivered() AND Tools::isSubmit('reinjectQuantities') AND !$is_philea AND !$is_braderie)
|
||
){
|
||
if(
|
||
(($is_philea || $is_braderie) && !$order->hasBeenShipped() && !$order->hasBeenDelivered())
|
||
|| (!$is_philea && !$is_braderie)
|
||
){
|
||
$reinjectableQuantity = (int)($orderDetail->product_quantity) - (int)($orderDetail->product_quantity_reinjected);
|
||
$quantityToReinject = $qtyCancelProduct > $reinjectableQuantity ? $reinjectableQuantity : $qtyCancelProduct;
|
||
|
||
if (!Product::reinjectQuantities($orderDetail, $quantityToReinject)) {
|
||
$errors++;
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('Cannot re-stock product').' <span class="bold">'.$orderDetail->product_name.'</span>');
|
||
}
|
||
else
|
||
{
|
||
$updProductAttributeID = !empty($orderDetail->product_attribute_id) ? (int)($orderDetail->product_attribute_id) : NULL;
|
||
$newProductQty = Product::getQuantity((int)($orderDetail->product_id), $updProductAttributeID);
|
||
$product = get_object_vars(new Product((int)($orderDetail->product_id), false, (int)($cookie->id_lang)));
|
||
if (!empty($orderDetail->product_attribute_id))
|
||
{
|
||
$updProduct['quantity_attribute'] = (int)($newProductQty);
|
||
$product['quantity_attribute'] = $updProduct['quantity_attribute'];
|
||
}
|
||
else
|
||
{
|
||
$updProduct['stock_quantity'] = (int)($newProductQty);
|
||
$product['stock_quantity'] = $updProduct['stock_quantity'];
|
||
}
|
||
Hook::updateQuantity($product, $order);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Delete product
|
||
if (!$order->deleteProduct($order, $orderDetail, $qtyCancelProduct)) {
|
||
$errors++;
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred during deletion of the product.').' <span class="bold">'.$orderDetail->product_name.'</span>');
|
||
}
|
||
Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $id_order_detail));
|
||
}
|
||
|
||
$params['{lastname}'] = $customer->lastname;
|
||
$params['{firstname}'] = $customer->firstname;
|
||
$params['{id_order}'] = $order->id;
|
||
|
||
/* PRODUIT REMBOURSE */
|
||
$products_refund = "";
|
||
$total_refund = 0;
|
||
foreach ($productList as $id_order_detail => $qty) {
|
||
$details_refund = new OrderDetail($id_order_detail);
|
||
|
||
$tprice = $details_refund->product_price * (1 - $details_refund->reduction_percent / 100) - $details_refund->reduction_amount;
|
||
$tprice = $tprice * ( 1+ $details_refund->tax_rate / 100 );
|
||
|
||
$products_refund .= "
|
||
<tr>
|
||
<td>". $details_refund->product_name . "</td>
|
||
<td style='text-align:right;'>" . Tools::displayPrice($tprice) . " </td>
|
||
<td style='text-align:right;'>". (int)$qty ."</td>
|
||
<td style='text-align:right;'>" . Tools::displayPrice(($tprice * (int)$qty)) . "</td>
|
||
</tr>
|
||
";
|
||
$total_refund = $total_refund + ($tprice * (int)$qty);
|
||
}
|
||
|
||
$params['{products}'] = $products_refund;
|
||
$params['{total_products}'] = Tools::displayPrice($total_refund);
|
||
|
||
$fraisport = "";
|
||
if(isset($_POST['shippingBack']))
|
||
{
|
||
$order = new Order($details_refund->id_order);
|
||
Module::hookExec('cancelShipping', array('order' => $order));
|
||
$fraisport .= "
|
||
<tr style='text-align:right;'>
|
||
<td colspan='3' style='background-color:#e2e2e1; padding:0.6em 0.4em;'>Frais de port</td>
|
||
<td style='background-color:#e2e2e1; padding:0.6em 0.4em;'>" . Tools::displayPrice($order->total_shipping) . "</td>
|
||
</tr>
|
||
";
|
||
}
|
||
$params['{fraisport}'] = $fraisport;
|
||
|
||
if (isset($_POST['generateCreditSlip']) AND $errors==0)
|
||
{
|
||
if (!OrderSlip::createOrderSlip($order, $full_product_list, $full_quantity_list, isset($_POST['shippingBack']))) {
|
||
HelperFormBootstrap::displayErrors(Tools::displayError('Cannot generate credit slip'));
|
||
$errors++;
|
||
} else {
|
||
Module::hookExec('orderSlip', array(
|
||
'order' => $order,
|
||
'productList' => $id_order_details,
|
||
'qtyList' => $refund_quantities,
|
||
'shippingBack' => isset($_POST['shippingBack']) ? true : false,
|
||
));
|
||
|
||
@Mail::Send((int)$order->id_lang, 'credit_slip', Mail::l('New credit slip regarding your order', $order->id_lang),
|
||
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL,
|
||
_PS_MAIL_DIR_, true);
|
||
}
|
||
}
|
||
|
||
// update order state if it's partial
|
||
if($order->getCurrentState() == 17) {
|
||
$partial = true;
|
||
|
||
$to_send = Db::getInstance()->ExecuteS('
|
||
SELECT `id_order_detail`, (`product_quantity` - IF(`product_quantity_return` > 0, `product_quantity_return`, `product_quantity_refunded`)) AS `quantity`, `product_id`
|
||
FROM `'._DB_PREFIX_.'order_detail`
|
||
WHERE `id_order` = '.(int) $order->id.'
|
||
AND (`product_quantity` - IF(`product_quantity_return` > 0, `product_quantity_return`, `product_quantity_refunded`)) > 0
|
||
');
|
||
|
||
if(count($to_send) == 0) {
|
||
$partial = false;
|
||
} else {
|
||
include_once dirname(__FILE__).'/../../modules/privatesales/Sale.php';
|
||
$quantities_sent = array();
|
||
|
||
$product_ids = array();
|
||
foreach(Db::getInstance()->ExecuteS('
|
||
SELECT `product_id`
|
||
FROM `'._DB_PREFIX_.'order_detail`
|
||
WHERE `id_order` = '.(int) $order->id.'
|
||
') as $row) {
|
||
$product_ids[] = (int) $row['product_id'];
|
||
}
|
||
|
||
/**
|
||
* @Override Philea
|
||
*/
|
||
if(Db::getInstance()->getRow('
|
||
SELECT *
|
||
FROM `'._DB_PREFIX_.'philea_parcel`
|
||
WHERE `id_order` = '.(int) $order->id.'
|
||
')) {
|
||
foreach(Db::getInstance()->ExecuteS('
|
||
SELECT c.`id_product`
|
||
FROM `'._DB_PREFIX_.'product_ps_cache` c
|
||
WHERE c.`id_product` IN ('.implode(', ', $products_ids).')
|
||
') as $row) {
|
||
$quantities_sent[(int) $row['id_product']] = -1;
|
||
}
|
||
}
|
||
|
||
$parcel_quantities = array();
|
||
foreach($to_send as $ts) {
|
||
if(!isset($quantities_sent[(int) $ts['product_id']])) {
|
||
$parcel_quantities[(int) $ts['id_order_detail']] = $ts;
|
||
}
|
||
}
|
||
|
||
if(count($parcel_quantities) > 0) {
|
||
$partial = false;
|
||
$sent_logistics = array();
|
||
|
||
foreach(Db::getInstance()->ExecuteS('
|
||
SELECT SUM(`quantity`) AS `quantity`, `id_order_detail`
|
||
FROM `'._DB_PREFIX_.'lapostews`
|
||
WHERE `id_order_detail` IN ('.implode(', ', array_keys($parcel_quantities)).')
|
||
GROUP BY `id_order_detail`
|
||
') as $row) {
|
||
$sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
|
||
}
|
||
|
||
foreach(Db::getInstance()->ExecuteS('
|
||
SELECT SUM(`quantity`) AS `quantity`, `id_order_detail`
|
||
FROM `'._DB_PREFIX_.'mondialrelay_parcel`
|
||
WHERE `id_order_detail` IN ('.implode(', ', array_keys($parcel_quantities)).')
|
||
GROUP BY `id_order_detail`
|
||
') as $row) {
|
||
$sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
|
||
}
|
||
|
||
foreach(Db::getInstance()->ExecuteS('
|
||
SELECT SUM(`quantity`) AS `quantity`, `id_order_detail`
|
||
FROM `'._DB_PREFIX_.'exapaqws`
|
||
WHERE `id_order_detail` IN ('.implode(', ', array_keys($parcel_quantities)).')
|
||
GROUP BY `id_order_detail`
|
||
') as $row) {
|
||
$sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
|
||
}
|
||
|
||
if(count($sent_logistics) == 0) {
|
||
$partial = true;
|
||
} else {
|
||
foreach($parcel_quantities as $k => $v) {
|
||
if(!isset($sent_logistics[(int) $k])) {
|
||
$partial = true;
|
||
break;
|
||
} else {
|
||
if($sent_logistics[(int) $k] < $v['quantity']) {
|
||
$partial = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
$partial = false;
|
||
}
|
||
|
||
if(!$partial) {
|
||
global $cookie;
|
||
Db::getInstance()->ExecuteS('
|
||
INSERT INTO `'._DB_PREFIX_.'order_history`
|
||
VALUES (
|
||
DEFAULT,
|
||
'.(int) $cookie->id_employee.',
|
||
'.(int) $order->id.',
|
||
'.Configuration::get('PS_OS_SHIPPING').',
|
||
NOW()
|
||
)
|
||
');
|
||
Db::getInstance()->ExecuteS('
|
||
INSERT INTO `'._DB_PREFIX_.'order_state_current`
|
||
VALUES (
|
||
'.(int) $order->id.',
|
||
'.Configuration::get('PS_OS_SHIPPING').',
|
||
NOW()
|
||
)
|
||
ON DUPLICATE KEY UPDATE
|
||
`id_order_state` = '.Configuration::get('PS_OS_SHIPPING').',
|
||
`date_upd` = NOW()
|
||
');
|
||
$newOS = new OrderState((int)(Configuration::get('PS_OS_SHIPPING')), $order->id_lang);
|
||
Module::hookExec('updateOrderStatus', array('newOrderStatus' => $newOS, 'id_order' => (int)($order->id)));
|
||
}
|
||
}
|
||
}
|
||
HelperFormBootstrap::displaySuccess('Remboursement Effectué');
|
||
}
|
||
} elseif(Tools::isSubmit('submitResendParcel') && Tools::getValue('id_order_return') && ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order))) {
|
||
|
||
$products = Tools::getValue('resendQuantity');
|
||
$parcel_carrier = Tools::getValue('parcel_carrier');
|
||
$weight = Tools::getValue('weight');
|
||
|
||
if($parcel_carrier == 'mondialrelay') {
|
||
HelperFormBootstrap::displayWarning('Option en cours de developpement...');
|
||
return;
|
||
}
|
||
|
||
if(!empty($products)) {
|
||
if($weight < 0.24) {
|
||
$weight = 0.24;
|
||
}
|
||
|
||
$qty_to_send = 0;
|
||
foreach ($products as $k => $qty) {
|
||
$qty_to_send+=$qty;
|
||
}
|
||
if($qty_to_send==0) {
|
||
HelperFormBootstrap::displayWarning('Aucune quantité renseignée');
|
||
return;
|
||
}
|
||
|
||
$result = $logistics_carriers[$parcel_carrier]->registerParcel($order, $products, $weight);
|
||
if($result[0] != '') {
|
||
HelperFormBootstrap::displayErrors($result[0]);
|
||
return;
|
||
}
|
||
|
||
$render = $logistics_carriers[$parcel_carrier]->renderLabel($order, $weight, $result[1]);
|
||
if($render === 'pr_error') {
|
||
HelperFormBootstrap::displayErrors($this->l('Unknown delivery point'));
|
||
} elseif($render === 'route_error') {
|
||
HelperFormBootstrap::displayErrors($this->l('Route not found'));
|
||
} elseif($render !== FALSE) {
|
||
$this->printLabel($render); // comment in dev
|
||
|
||
if($_SERVER['REMOTE_ADDR'] != '109.190.53.175'
|
||
&& $_SERVER['REMOTE_ADDR'] != '78.226.56.137'
|
||
&& $_SERVER['REMOTE_ADDR'] != '88.163.22.223'
|
||
&& $_SERVER['REMOTE_ADDR'] != '37.160.139.229'
|
||
&& substr($_SERVER['REMOTE_ADDR'], 0, 2) != '37') {
|
||
$products_sent = '';
|
||
|
||
$products_names = array();
|
||
foreach(Db::getInstance()->ExecuteS('
|
||
SELECT `id_order_detail`, `product_name`
|
||
FROM `'._DB_PREFIX_.'order_detail`
|
||
WHERE `id_order_detail` IN ('.implode(', ', array_keys($products)).')
|
||
') as $p) {
|
||
$products_names[(int) $p['id_order_detail']] = $p['product_name'];
|
||
}
|
||
|
||
$id_order_return = (int) Tools::getValue('id_order_return');
|
||
$logistics_carriers[$parcel_carrier]->logParcel($result[1], $products, $id_order_return);
|
||
|
||
foreach($products as $k => $v) {
|
||
if($v > 0) {
|
||
$products_sent .= '<br />'."\r\n".$v.' x '.(isset($products_names[$k])? $products_names[$k]: '--');
|
||
}
|
||
}
|
||
|
||
$logistics_carriers[$parcel_carrier]->addOrderHistory($result[1], $order, $products_sent);
|
||
|
||
HelperFormBootstrap::displaySuccess('Etiquette envoyée à l\'imprimante');
|
||
|
||
$orderReturn = new OrderReturn($id_order_return);
|
||
$orderReturn->state = 5; // return is ended
|
||
if ($orderReturn->save())
|
||
{
|
||
$orderReturnState = new OrderReturnState($orderReturn->state);
|
||
Db::getInstance()->ExecuteS('
|
||
INSERT INTO `'._DB_PREFIX_.'order_return_history`
|
||
VALUES (
|
||
DEFAULT,
|
||
'.(int) $cookie->id_employee.',
|
||
'.(int) $orderReturn->id.',
|
||
'.(int) $orderReturn->state.',
|
||
NOW()
|
||
)
|
||
');
|
||
}
|
||
}
|
||
|
||
} else {
|
||
HelperFormBootstrap::displayErrors($this->l('An error happened during the label rendering'));
|
||
}
|
||
} else {
|
||
HelperFormBootstrap::displayWarning('Aucune quantité renseignée');
|
||
}
|
||
} elseif(Tools::isSubmit('submitDetails') && Tools::getValue('id_order_return') && Tools::getValue('id_order_detail')){
|
||
$id_order_return = (int) Tools::getValue('id_order_return');
|
||
$id_order_detail = (int) Tools::getValue('id_order_detail');
|
||
$id_instruction = (int) Tools::getValue('instruction');
|
||
$id_reason = (int) Tools::getValue('reason');
|
||
Db::getInstance()->Execute('
|
||
UPDATE `'._DB_PREFIX_.'order_return_detail_qty`
|
||
SET reason = '.$id_reason.', instruction='.$id_instruction.'
|
||
WHERE id_order_detail='.$id_order_detail.' AND id_order_return='.$id_order_return.'
|
||
');
|
||
HelperFormBootstrap::displaySuccess('Mise à jour effectuée');
|
||
|
||
} elseif(Tools::isSubmit('submitComment') && Tools::getValue('id_order_return')){
|
||
$id_order_return = (int) Tools::getValue('id_order_return');
|
||
$comment = Tools::getValue('comment');
|
||
$return_link = Db::getInstance()->getRow('
|
||
SELECT *
|
||
FROM `'._DB_PREFIX_.'order_return_link`
|
||
WHERE id_order_return='.$id_order_return.'
|
||
');
|
||
if($return_link){
|
||
$ok = Db::getInstance()->execute('
|
||
UPDATE `'._DB_PREFIX_.'order_return_link`
|
||
SET return_comment = "'.pSQL($comment).'"
|
||
WHERE id_order_return='.$id_order_return.'
|
||
');
|
||
} else {
|
||
$ok = Db::getInstance()->execute('
|
||
INSERT INTO `'._DB_PREFIX_.'order_return_link`
|
||
VALUES (
|
||
'.(int) $id_order_return.',
|
||
'.(int) $cookie->id_employee.',
|
||
NOW(),
|
||
1,
|
||
0.0,
|
||
"mondialrelay",
|
||
"0",
|
||
"",
|
||
"'.pSQL($comment).'"
|
||
)
|
||
');
|
||
}
|
||
if($ok) {
|
||
HelperFormBootstrap::displaySuccess('Mise à jour effectuée');
|
||
} else {
|
||
HelperFormBootstrap::displayErrors('La mise à jour n\'a pas pu s\'effectuer');
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
public function display()
|
||
{
|
||
global $cookie, $currentIndex;
|
||
|
||
if($return_number = Tools::getValue('return_number')) {
|
||
if($return = Db::getInstance()->getRow('
|
||
SELECT *
|
||
FROM `'._DB_PREFIX_.'order_return_link`
|
||
WHERE `return_number` = "'.pSQL($return_number).'"
|
||
')) {
|
||
header('Location: /adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token'));
|
||
exit;
|
||
}
|
||
}
|
||
|
||
if($return_order = Tools::getValue('return_order')) {
|
||
if($returns = Db::getInstance()->executeS('
|
||
SELECT *
|
||
FROM `'._DB_PREFIX_.'order_return`
|
||
WHERE `id_order` = "'.(int)($return_order).'"
|
||
')) {
|
||
if($returns && count($returns) == 1) {
|
||
header('Location: /adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $returns[0]['id_order_return'].'&updateorder_return&token='.Tools::getValue('token'));
|
||
exit;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (isset($_GET['updateorder_return'])) {
|
||
|
||
if(isset($_GET['ok'])){
|
||
switch ($_GET['ok']) {
|
||
case '2':
|
||
$success_mess = 'Mise à jour enregistrée';
|
||
break;
|
||
case '3':
|
||
$success_mess = 'Votre message a bien été envoyé';
|
||
break;
|
||
case '4':
|
||
$success_mess = 'Les instructions on été renvoyées';
|
||
break;
|
||
case '5':
|
||
$success_mess = 'Le nouveau statut de la commande a bien été enregistré';
|
||
break;
|
||
default:
|
||
$success_mess = 'Mise à jour enregistrée';
|
||
break;
|
||
}
|
||
HelperFormBootstrap::displaySuccess($success_mess);
|
||
}
|
||
$this->displayForm();
|
||
echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
|
||
} else {
|
||
$this->displaylist();
|
||
}
|
||
}
|
||
|
||
public function displayForm()
|
||
{
|
||
global $cookie, $currentIndex;
|
||
|
||
if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return)) {
|
||
$orderReturn = new OrderReturn($id_order_return);
|
||
if (!Validate::isLoadedObject($orderReturn)) {
|
||
die(Tools::displayError());
|
||
}
|
||
}
|
||
|
||
$instructions = array(
|
||
1 => 'Remboursement + Mise en stock',
|
||
2 => 'Échange',
|
||
3 => 'Défectueux',
|
||
4 => 'Commande à ré-expédier',
|
||
5 => 'Commande à rembourser',
|
||
);
|
||
|
||
$reasons = array(
|
||
// 1 => 'CLIENT : Annulation pré-envoi',
|
||
2 => 'CLIENT : Rétractation post-envoi',
|
||
11 => 'CLIENT : Annulation pour ré-achat',
|
||
4 => 'FEUR : Problème SAV',
|
||
5 => 'FEUR : Produit manquant',
|
||
3 => 'BBB : Erreur Achat / Prod',
|
||
6 => 'BBB : Erreur Logistique',
|
||
8 => 'BBB : Pbme Site / Paiment',
|
||
12 => 'BBB : Suspicion de fraude',
|
||
9 => 'TRANS : Colis détruit',
|
||
10 => 'TRANS : Colis perdu',
|
||
7 => 'Autre'
|
||
);
|
||
|
||
$carriers_socol = explode(',', Configuration::get('ANT_CARRIERS_SOCOL'));
|
||
$carriers_mr = explode(',', Configuration::get('ANT_CARRIERS_MR'));
|
||
$order = new Order($orderReturn->id_order);
|
||
$cart = new Cart((int)$order->id_cart);
|
||
$carrier = new Carrier((int)($order->id_carrier));
|
||
$addressDelivery = new Address((int)$order->id_address_delivery);
|
||
$addressInvoice = new Address((int)$order->id_address_invoice);
|
||
$customer = new Customer((int)$order->id_customer);
|
||
$data = $this->getOrderDetail($cart,(int)$cart->id_lang,$order);
|
||
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
|
||
$orderStates = OrderState::getOrderStates((int)($cookie->id_lang));
|
||
$shipping_numbers = Db::getInstance()->ExecuteS('
|
||
SELECT DISTINCT lpws.`shipping_number`, lpws.`date_add`
|
||
FROM `'._DB_PREFIX_.'lapostews` lpws
|
||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = lpws.`id_order_detail`)
|
||
WHERE `id_order` ='. (int)$order->id
|
||
);
|
||
$shipping_numbers2 = Db::getInstance()->ExecuteS('
|
||
SELECT DISTINCT ppp.`shipping_number`, ppp.`date_add`
|
||
FROM `'._DB_PREFIX_.'philea_parcel` ppp
|
||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = ppp.`id_order_detail`)
|
||
WHERE od.`id_order` ='. (int)$order->id
|
||
);
|
||
$shipping_numbers3 = Db::getInstance()->ExecuteS('
|
||
SELECT DISTINCT mrp.`shipping_number`, mrp.`date_add`
|
||
FROM `'._DB_PREFIX_.'mondialrelay_parcel` mrp
|
||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = mrp.`id_order_detail`)
|
||
WHERE od.`id_order` ='. (int)$order->id
|
||
);
|
||
$discounts = $order->getDiscounts();
|
||
$query_thread = Db::getInstance()->getValue('
|
||
SELECT `id_customer_thread`
|
||
FROM `'._DB_PREFIX_.'customer_thread`
|
||
WHERE id_customer ='.(int)$order->id_customer.' AND id_order = '.(int)$order->id.'
|
||
');
|
||
if(!$query_thread) {
|
||
$query_thread = Db::getInstance()->getValue('
|
||
SELECT `id_customer_thread`
|
||
FROM `'._DB_PREFIX_.'customer_thread`
|
||
WHERE id_customer ='.(int)$order->id_customer.'
|
||
ORDER BY `date_upd` DESC
|
||
');
|
||
}
|
||
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'
|
||
);
|
||
}
|
||
|
||
$last_order_message = Db::getInstance()->getRow('
|
||
SELECT om.*, e.firstname, e.lastname
|
||
FROM `'._DB_PREFIX_.'message` om
|
||
LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = om.id_employee)
|
||
WHERE om.id_order = '.(int)$order->id.' AND om.id_employee!=0 AND om.private=1
|
||
ORDER BY om.date_add DESC
|
||
');
|
||
|
||
$parcel_sent = Db::getInstance()->ExecuteS('
|
||
SELECT lpr.*, od.`product_name`
|
||
FROM '._DB_PREFIX_.'lapostews_return lpr
|
||
LEFT JOIN '._DB_PREFIX_.'order_detail od ON (lpr.id_order_detail = od.id_order_detail)
|
||
WHERE lpr.id_order_return = '.(int)($orderReturn->id).'
|
||
ORDER BY lpr.date_add DESC'
|
||
);
|
||
|
||
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee));
|
||
$returnProducts = OrderReturn::getOrdersReturnProducts($orderReturn->id, $order);
|
||
$orderReturnState = new OrderReturnState($orderReturn->state);
|
||
|
||
$return_history = Db::getInstance()->ExecuteS('
|
||
SELECT rh.*, orsl.`name` as state, CONCAT(e.`firstname`,\' \',e.`lastname`) as employee
|
||
FROM '._DB_PREFIX_.'order_return_history rh
|
||
LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = rh.`id_order_return_state` AND orsl.`id_lang` = '.(int)($cookie->id_lang).')
|
||
LEFT JOIN '._DB_PREFIX_.'employee e ON (e.`id_employee` = rh.`id_employee`)
|
||
WHERE rh.`id_order_return` = '.(int)$orderReturn->id.'
|
||
ORDER BY rh.`date_add` DESC
|
||
');
|
||
|
||
$other_returnProducts = Db::getInstance()->ExecuteS('
|
||
SELECT a.*, orsl.`name`, ord.`id_order_detail`, ord.`qty`
|
||
FROM '._DB_PREFIX_.'order_return a
|
||
LEFT JOIN '._DB_PREFIX_.'order_return_detail_qty ord ON (ord.`id_order_return` = a.`id_order_return`)
|
||
LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)($cookie->id_lang).')
|
||
WHERE a.id_order='.(int)$order->id.' AND a.id_order_return != '.(int)$orderReturn->id.'
|
||
');
|
||
|
||
$colorStates = array(
|
||
1 => "anticon anticon-hour-glass text-orange",
|
||
2 => "anticon anticon-hour-glass text-orange",
|
||
3 => "anticon anticon-box-add text-orange",
|
||
4 => "anticon anticon-cross text-rose",
|
||
5 => "anticon anticon-checkmark text-green-light",
|
||
6 => "anticon anticon-warning text-danger",
|
||
);
|
||
|
||
$return_link = Db::getInstance()->getRow('
|
||
SELECT `return_number`, `link`, `return_comment`
|
||
FROM `'._DB_PREFIX_.'order_return_link`
|
||
WHERE `id_order_return` = '.(int) $id_order_return.'
|
||
');
|
||
|
||
$helper = new HelperFormBootstrap();
|
||
$helper->_select2 = true;
|
||
$helper->_inputMask = true;
|
||
$html = $helper->renderStyle();
|
||
$html .= '
|
||
<div class="modal fade" tabindex="-1" role="dialog" id="returnDetailModal">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
<form action="'.$currentIndex.'&submitDetails=1&updateorder_return&id_order_return='.(int)$id_order_return.'&token='.$this->token.'" method="post">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title">Changer les informations pour ce produit</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<input type="hidden" value="'.$id_order_return.'" id="id_order_return" name="id_order_return">
|
||
<input type="hidden" value="0" id="id_order_detail" name="id_order_detail">
|
||
<div class="form-group">
|
||
<label class="control-label">Raison</label>
|
||
<select class="form-control" id="reason" name="reason">
|
||
<option value="0">Changer les instructions</option>
|
||
<option value="2">CLIENT : Rétractation post-envoi</option>
|
||
<option value="11">CLIENT : Annulation pour ré-achat</option>
|
||
<option value="4">FEUR : Problème SAV</option>
|
||
<option value="5">FEUR : Produit manquant</option>
|
||
<option value="3">BBB : Erreur Achat / Prod</option>
|
||
<option value="6">BBB : Erreur Logistique</option>
|
||
<option value="8">BBB : Pbme Site / Paiment</option>
|
||
<option value="12">BBB : Suspicion de fraude</option>
|
||
<option value="9">TRANS : Colis détruit</option>
|
||
<option value="10">TRANS : Colis perdu</option>
|
||
<option value="7">Autre</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="control-label">Instructions</label>
|
||
<select class="form-control" id="instruction" name="instruction">
|
||
<option value="0">Changer la Raison</option>
|
||
<option value="1">Remboursement + Mise en stock</option>
|
||
<option value="2">Échange</option>
|
||
<option value="3">Défectueux</option>
|
||
<option value="4">Commande à ré-expédier</option>
|
||
<option value="5">Commande à rembourser</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
|
||
<button type="submit" class="btn btn-primary" name="submitDetails">Enregistrer</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal fade" tabindex="-1" role="dialog" id="returnCommentModal">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
<form action="'.$currentIndex.'&submitComment=1&updateorder_return&id_order_return='.(int)$id_order_return.'&token='.$this->token.'" method="post">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title">Modifier le commentaire</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<input type="hidden" value="'.$id_order_return.'" id="id_order_return" name="id_order_return">
|
||
<div class="form-group">
|
||
<textarea class="form-control" rows="4" name="comment">'.($return_link && !empty($return_link['return_comment'])?$return_link['return_comment']:'').'</textarea>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
|
||
<button type="submit" class="btn btn-primary" name="submitComment">Enregistrer</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2 style="font-size:24px;"><span class="anticon anticon-loop" style="font-size:24px;"></span> Retour #'.$id_order_return.'</h2>
|
||
<p class="pull-right">'.$orderReturnState->name[(int)$cookie->id_lang].' <span style="font-size:24px;" class="'.$colorStates[$orderReturn->state].'"></span></p>
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="row">
|
||
<div class="col-md-7">
|
||
<div>';
|
||
$html .= '<p class="text-purple-dark" style="font-weight:bold;"><span class="anticon anticon-qrcode"></span> Lien retour Etiquette MR : '.($return_link && !empty($return_link['link'])? '<a style="color:#444;" href="'.$return_link['link'].'" onclick="window.open(this.href); return false;">'.$return_link['return_number'].'</a> <a class="text-purple-dark" title="Renvoyer les instructions retour" href="'.$currentIndex.'&send_return_instruction=1&updateorder_return&id_order_return='.$id_order_return.'&id_order='.(int)$order->id.'&token='.$this->token.'"><i class="glyphicon glyphicon-send"></i></a>':'Pas de lien retour').'<p>';
|
||
$html .= '</div>
|
||
<table class="table">
|
||
<thead>
|
||
<tr>
|
||
<th>'.$this->l('Produit').'</th>
|
||
<th align="center">'.$this->l('Qté').'</th>
|
||
<th align="center">'.$this->l('Instructions').'</th>
|
||
<th align="center">'.$this->l('Action').'</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>';
|
||
$productReturned = array();
|
||
$reason_selected = 0;
|
||
foreach ($returnProducts AS $k => $product) {
|
||
$productReturned[] = $product['product_id'];
|
||
$img_path = '';
|
||
$img = Db::getInstance()->getRow('
|
||
SELECT id_image
|
||
FROM `'._DB_PREFIX_.'image` i
|
||
WHERE i.`id_product` = '.(int)$product['product_id'].'
|
||
AND i.`cover` = 1'
|
||
);
|
||
if (isset($img['id_image']) && !empty($img['id_image'])) {
|
||
$image_obj = new Image((int)$img['id_image']);
|
||
$img_path = (isset($image_obj)?$image_obj->getExistingImgPath():'');
|
||
}
|
||
|
||
$return_details = Db::getInstance()->getRow('
|
||
SELECT reason, instruction
|
||
FROM `'._DB_PREFIX_.'order_return_detail_qty`
|
||
WHERE id_order_return = '.(int)$orderReturn->id.'
|
||
AND id_order_detail = '.(int)$product['id_order_detail']
|
||
);
|
||
if (!isset($quantityDisplayed[(int)($product['id_order_detail'])]) OR (int)($product['product_quantity']) > (int)($quantityDisplayed[(int)($product['id_order_detail'])])) {
|
||
$reason_selected = (int)$return_details['reason'];
|
||
$html .='
|
||
<tr>
|
||
<td style="vertical-align:middle;color:#444;font-weight:bold;">
|
||
<a style="display: block;color:#444;" target="_blank" href="index.php?tab=AdminCatalog&id_product='.(int)($product['product_id']).'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" title="'.$this->l('View product').'">
|
||
<img style="display:inline-block;" width="50" src="'.(isset($img_path)?_THEME_PROD_DIR_.$img_path.'-small.jpg':'').'"/><span style="font-weight:bold;display:inline-block;margin-left:5px;width:210px;vertical-align:middle;">'.mb_strimwidth($product['product_name'], 0, 55, "...").'</span>
|
||
<div class="clearfix"></div>
|
||
</a>
|
||
</td>
|
||
<td align="center" style="vertical-align:middle;color:#444;">'.$product['product_quantity'].'</td>
|
||
<td align="center" style="vertical-align:middle;color:#444;font-size: 12px;">'.$instructions[(int)$return_details['instruction']].'</td>
|
||
<td align="center" style="vertical-align:middle;color:#444;">
|
||
<a style="color:#504d8b;" href="'.$currentIndex.'&deleteorder_return_detail&id_order_detail='.$product['id_order_detail'].'&id_order_return='.$orderReturn->id.'&token='.$this->token.'"><span class="anticon anticon-bin"></span></a>
|
||
<a style="cursor:pointer;color:#504d8b;" data-container="body" data-toggle="popover" data-placement="bottom" data-content="'.$reasons[(int)$return_details['reason']].'"><i class="glyphicon glyphicon-info-sign"></i></a>
|
||
<a style="cursor:pointer;color:#504d8b;" data-toggle="modal" data-target="#returnDetailModal" data-detail="'.$product['id_order_detail'].'" data-instruction="'.$return_details['instruction'].'" data-reason="'.$return_details['reason'].'"><i class="glyphicon glyphicon-edit"></i></a>
|
||
</td>
|
||
</tr>';
|
||
}
|
||
}
|
||
$html .='</tbody>
|
||
</table>
|
||
</div>
|
||
<div class="col-md-offset-1 col-md-4">
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">
|
||
'.$this->l('Commentaire').'
|
||
<a style="cursor:pointer;color:#fff;" class="pull-right" data-toggle="modal" data-target="#returnCommentModal"><i class="glyphicon glyphicon-edit"></i></a>
|
||
</h5>
|
||
<p class="" style="margin-bottom:20px; padding:5px 20px;background:#efefef;">'.(($return_link && !empty($return_link['return_comment']))?$return_link['return_comment']:'Sans commentaire').'<p>';
|
||
|
||
if($return_history && !empty($return_history)) {
|
||
$html .= '
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">
|
||
'.$this->l('Statut').'
|
||
<a class="pull-right" style="color:#fff;" role="button" data-toggle="collapse" href="#collapseHistory" aria-expanded="false" aria-controls="collapseHistory">
|
||
<i class="anticon anticon-info"></i>
|
||
</a>
|
||
</h5>
|
||
<p class="text-center">
|
||
<b>'.$return_history[0]['state'].' <span style="font-size:24px;" class="'.$colorStates[$orderReturn->state].'"></span></b><br>('.$return_history[0]['employee'].' - '.date('d/m/Y H:i',strtotime($return_history[0]['date_add'])).')
|
||
</p>
|
||
|
||
<div class="collapse" id="collapseHistory">
|
||
<div class="well">
|
||
<table class="table">';
|
||
foreach ($return_history as $key => $history) {
|
||
$html .= '
|
||
<tr>
|
||
<td style="font-size:11px;">'.date('d/m/Y H:i',strtotime($history['date_add'])).'</td>
|
||
<td style="font-size:11px;font-weight:bold">'.$history['state'].'</td>
|
||
<td style="font-size:11px;">'.$history['employee'].'</td>
|
||
</tr>';
|
||
}
|
||
$html .= '
|
||
</table>
|
||
</div>
|
||
</div>';
|
||
}
|
||
$html.='</div>
|
||
</div>';
|
||
if($other_returnProducts && !empty($other_returnProducts)){
|
||
$html .= '
|
||
<div class="row">
|
||
<div class="col-md-8">
|
||
<p class="text-purple-dark" style="font-weight:bold;">Autre(s) produit(s) en retour pour cette commande : </p>
|
||
<table class="table">
|
||
<thead>
|
||
<tr>
|
||
<th style="background:#efefef;color:#504d8b;"># Retour</th>
|
||
<th style="background:#efefef;color:#504d8b;">'.$this->l('Produit').'</th>
|
||
<th style="background:#efefef;color:#504d8b;text-align:center;">'.$this->l('Qté').'</th>
|
||
<th style="background:#efefef;color:#504d8b;text-align:center;">'.$this->l('Statut').'</th>
|
||
<th style="background:#efefef;color:#504d8b;text-align:center;">'.$this->l('Action').'</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>';
|
||
foreach ($other_returnProducts as $key => $return_product) {
|
||
$order_detail = new OrderDetail((int)$return_product['id_order_detail']);
|
||
$img_path = '';
|
||
$img = Db::getInstance()->getRow('
|
||
SELECT id_image
|
||
FROM `'._DB_PREFIX_.'image` i
|
||
WHERE i.`id_product` = '.(int)$order_detail->product_id.'
|
||
AND i.`cover` = 1'
|
||
);
|
||
if (isset($img['id_image']) && !empty($img['id_image'])) {
|
||
$image_obj = new Image((int)$img['id_image']);
|
||
$img_path = (isset($image_obj)?$image_obj->getExistingImgPath():'');
|
||
}
|
||
$html .= '
|
||
<tr>
|
||
<td style="text-align:center;vertical-align:middle;color:#444;font-weight:bold;">'.(int) $return_product['id_order_return'].'</td>
|
||
<td style="vertical-align:middle;color:#444;font-weight:bold;">
|
||
<a style="display: block;color:#444;" target="_blank" href="index.php?tab=AdminCatalog&id_product='.(int)($order_detail->product_id).'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" title="'.$this->l('View product').'">
|
||
<img style="display:inline-block;" width="50" src="'.(isset($img_path)?_THEME_PROD_DIR_.$img_path.'-small.jpg':'').'"/><span style="font-weight:bold;display:inline-block;margin-left:5px;width:150px;vertical-align:middle;">'.mb_strimwidth($order_detail->product_name, 0, 55, "...").'</span>
|
||
<div class="clearfix"></div>
|
||
</a>
|
||
</td>
|
||
<td align="center" style="vertical-align:middle;color:#444;">'.$return_product['qty'].'</td>
|
||
<td align="center" style="vertical-align:middle;color:#444;"><span style="font-size:24px;" class="'.$colorStates[$return_product['state']].'"></span> '.$return_product['name'].'</td>
|
||
<td align="center" style="vertical-align:middle;color:#444;"><a href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return_product['id_order_return'].'&updateorder_return&token='.Tools::getValue('token').'" title="voir"><span class="anticon anticon-eye text-purple-dark"></span></a></td>
|
||
</tr>';
|
||
}
|
||
$html .= '</tbody>
|
||
</table>
|
||
</div>
|
||
</div>';
|
||
}
|
||
$html .='</div>
|
||
</div>
|
||
</div>
|
||
</div>';
|
||
|
||
$html .= '
|
||
<div class="row">
|
||
<div class="col-md-8">
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="glyphicon glyphicon-tag"></span> Résumé Commande <a target="_blank" href="?tab=AdminOrders&id_order='.(int)$order->id.'&vieworder&token='.(Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee))).'">(#'.(int)$order->id.')</a> - '.$customer->firstname.' '.$customer->lastname.' <a href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee)).'">('.$this->l('#').$customer->id.')</a></h2>
|
||
<a class="pull-right text-purple-dark" style="color:#fff;" role="button" data-toggle="collapse" href="#collapseOrder" aria-expanded="false" aria-controls="collapseOrder">
|
||
<i style="font-size:20px;" class="anticon anticon-info"></i>
|
||
</a>
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="row">
|
||
<div class="col-md-12 collapse" id="collapseOrder">
|
||
<div class="row"/>
|
||
<div class="col-md-6">
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;"><span class="anticon anticon-credit-card"></span> Détails paiement</h5>
|
||
<div style="text-align:center;">'.Tools::substr($order->payment, 0, 32).' '.($order->module ? '('.$order->module.')' : '').'</div>
|
||
<div style="padding:10px 30px;">
|
||
<table class="table table-condensed" width="100%;" cellspacing="0" cellpadding="0">
|
||
<tr style="font-size: 13px"><td class="text-purple-dark">'.$this->l('Products').'</td><td align="right" class="text-purple-dark">'.Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency, false).'</td></tr>
|
||
'.($order->total_discounts > 0 ? '<tr style="font-size: 13px"><td class="text-purple-dark">'.$this->l('Discounts').'</td><td align="right" class="text-purple-dark">-'.Tools::displayPrice($order->total_discounts, $currency, false).'</td></tr>' : '').'
|
||
'.($order->total_wrapping > 0 ? '<tr style="font-size: 13px"><td class="text-purple-dark">'.$this->l('Wrapping').'</td><td align="right" class="text-purple-dark">'.Tools::displayPrice($order->total_wrapping, $currency, false).'</td></tr>' : '').'
|
||
<tr style="font-size: 13px"><td class="text-purple-dark">'.$this->l('Shipping').'</td><td align="right" class="text-purple-dark">'.Tools::displayPrice($order->total_shipping, $currency, false).'</td></tr>
|
||
<tr style="font-size: 16px"><td>'.$this->l('Total').'</td><td align="right" class="text-rose">'.Tools::displayPrice($order->total_paid, $currency, false).($order->total_paid != $order->total_paid_real ? '<br /><font color="red">('.$this->l('Paid:').' '.Tools::displayPrice($order->total_paid_real, $currency, false, false).')</font>' : '').'</td></tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;"><span class="anticon anticon-truck"></span> Transporteur</h5>
|
||
<p class="text-center">'.$data['carrier_name'].'</p>
|
||
<ul class="">';
|
||
if(count($shipping_numbers) > 0){
|
||
foreach ($shipping_numbers as $key => $number) {
|
||
$date = new DateTime($number['date_add']);
|
||
$html .= '<li><strong>'. $number['shipping_number'] .'</strong> ajouté le '. $date->format('d/m/Y') .'</li>';
|
||
}
|
||
}
|
||
if(count($shipping_numbers2) > 0){
|
||
foreach ($shipping_numbers2 as $key => $number) {
|
||
$date = new DateTime($number['date_add']);
|
||
$html .= '<li><strong>'. $number['shipping_number'] .'</strong> ajouté le '. $date->format('d/m/Y') .'</li>';
|
||
}
|
||
}
|
||
if(count($shipping_numbers3) > 0){
|
||
foreach ($shipping_numbers3 as $key => $number) {
|
||
$date = new DateTime($number['date_add']);
|
||
$html .= '<li><strong>'. $number['shipping_number'] .'</strong> ajouté le '. $date->format('d/m/Y') .'</li>';
|
||
}
|
||
}
|
||
if(count($parcel_sent) > 0){
|
||
foreach ($parcel_sent as $key => $number) {
|
||
$date = new DateTime($number['date_add']);
|
||
$html .= '<li><strong>'. $number['shipping_number'] .'</strong> ajouté le '. $date->format('d/m/Y') .'</li>';
|
||
}
|
||
}
|
||
$html .= '</ul>
|
||
</div>
|
||
</div>
|
||
<div class="row"/>
|
||
<div class="col-md-6">
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Adresse Facturation</h5>
|
||
<p style="padding:5px 20px;background:#efefef;">'.$data['order_invoice_address'].'</p>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">
|
||
Adresse Livraison
|
||
'.($cart->id_carrier!=(int)Configuration::get('ANT_CARRIER_DOM') && in_array($cart->id_carrier,$carriers_socol)?'<a style="color:#fff;cursor:pointer;" class="pull-right" id="changeAddress" data-url="scaddressedit.php?id_cart='.(int)$order->id_cart.'"><i class="glyphicon glyphicon-edit"></i></a>':'').'
|
||
'.(in_array($cart->id_carrier,$carriers_mr)?'<a style="color:#fff;" class="pull-right" id="changeAddress" data-url="mraddressedit.php?id_cart='.(int)$order->id_cart.'"><i class="glyphicon glyphicon-edit"></i></a>':'').'
|
||
'.($cart->id_carrier==(int)Configuration::get('ANT_CARRIER_DOM')?'<a style="color:#fff;" class="pull-right" href="?tab=AdminAddresses&id_address='.$addressDelivery->id.'&addaddress&realedit=1&id_order='.$order->id.($addressDelivery->id == $addressInvoice->id ? '&address_type=1' : '').'&token='.Tools::getAdminToken('AdminAddresses'.(int)(Tab::getIdFromClassName('AdminAddresses')).(int)($cookie->id_employee)).'&back='.urlencode($_SERVER['REQUEST_URI']).'"><i class="glyphicon glyphicon-edit"></i></a>':'').'
|
||
</h5>
|
||
<p style="padding:5px 20px;background:#efefef;">'.$data['order_address'].'</p>
|
||
</div>
|
||
</div>
|
||
<div class="clearfix"></div>
|
||
<div class="ln_solid"></div>
|
||
</div>
|
||
<div class="col-md-12">
|
||
<div class="panel-content">
|
||
<div class="form-group">
|
||
<div class="input-group">
|
||
<span class="input-group-addon"><i class="anticon anticon-barcode"></i></span>
|
||
<input type="text" data-table="product_detail" class="form-control input_ean" placeholder="Sélection par EAN..."/>
|
||
</div>
|
||
</div>
|
||
<form action="'.$currentIndex.'&submitCancelProduct=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
|
||
<div class="table-responsive">
|
||
<table id="product_detail" class="table table-custombordered" style="margin-bottom:0;">
|
||
<thead>
|
||
<tr>
|
||
<th><span class="anticon anticon-cart"></span> '.$this->l('Produit').'</th>
|
||
<th>'.$this->l('Prix U').'</th>
|
||
<th>'.$this->l('Qté').'</th>
|
||
'.($order->hasBeenPaid() ?'<th>'.$this->l('Remb').'*</th>':'').'
|
||
<th>'.$this->l('Stock').'</th>
|
||
<th>'.$this->l('Total').'</th>
|
||
<th class="text-center">'.($order->module ? ($order->module=="paybox"?'<span class="anticon anticon-credit-card"></span> ':'<span class="anticon anticon-paypal"></span> ') : '').'<span class="anticon anticon-redo2"></span></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>';
|
||
foreach ($order->getProducts() as $key => $product) {
|
||
if ($order->getTaxCalculationMethod() == PS_TAX_EXC) {
|
||
$product_price = $product['product_price'] + $product['ecotax'];
|
||
} else {
|
||
$product_price = $product['product_price_wt'];
|
||
}
|
||
|
||
if ($product['product_quantity'] > $product['customizationQuantityTotal'])
|
||
{
|
||
$quantity = $product['product_quantity'] - $product['customizationQuantityTotal'];
|
||
$stock = Db::getInstance()->getRow('
|
||
SELECT '.($product['product_attribute_id'] ? 'pa' : 'p').'.quantity
|
||
FROM '._DB_PREFIX_.'product p
|
||
'.($product['product_attribute_id'] ? 'LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON p.id_product = pa.id_product' : '').'
|
||
WHERE p.id_product = '.(int)($product['product_id']).'
|
||
'.($product['product_attribute_id'] ? 'AND pa.id_product_attribute = '.(int)($product['product_attribute_id']) : '')
|
||
);
|
||
|
||
$html .='
|
||
<tr '.(in_array($product['product_id'],$productReturned)?'style="background:rgba(234, 161, 193, 0.45);"':'').'>
|
||
<td style="vertical-align:middle;color:#444;">
|
||
<a style="color:#444;" href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
|
||
<span style="font-weight:bold;font-size:11px" class="productName">'.$product['product_name'].'</span><br />
|
||
'.($product['product_reference'] ? '<span style="font-size:10px">'.$this->l('Ref:').' '.$product['product_reference'].'</span><br />' : '')
|
||
.($product['product_supplier_reference'] ? '<span style="font-size:10px">'.$this->l('Ref Supplier:').' '.$product['product_supplier_reference'].'</span>' : '')
|
||
.'</a>
|
||
</td>
|
||
<td style=" width:70px;vertical-align:middle;color:#444;">'.Tools::displayPrice($product_price,$currency).'</td>
|
||
<td style="vertical-align:middle;color:#444;">'.$quantity.'</td>
|
||
'.($order->hasBeenPaid() ? '<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity"><span class="text-rose">'.(int)($product['product_quantity_refunded']).'</span> | <span class="text-rose">'.(int)($product['product_quantity_return']).'</span></td>' : '').'
|
||
<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity">'.(int)$stock['quantity'].'</td>
|
||
<td style=" width:70px;vertical-align:middle;color:#444;" align="center">'.Tools::displayPrice(Tools::ps_round($product_price, 2) * ((int)($product['product_quantity']) - $product['customizationQuantityTotal']), $currency, false).'</td>
|
||
<td width="70" style="vertical-align:middle;color:#444;">
|
||
<input class="form-control" type="number" data-ean="'.$product['product_ean13'].'" id="cancelQuantity_'.(int)($product['id_order_detail']).'" name="cancelQuantity['.(int)($product['id_order_detail']).']" min="0" max="'.((int)($product['product_quantity']) - (int)($product['product_quantity_return'] + $product['product_quantity_refunded'])).'" value="0" '.(((int)($product['product_quantity_return'] + $product['product_quantity_refunded']) >= (int)($product['product_quantity'])) ? 'disabled="disabled" ' : '').'/>
|
||
</td>
|
||
</tr>';
|
||
}
|
||
}
|
||
if (sizeof($discounts))
|
||
{
|
||
foreach ($discounts as $discount){
|
||
$html .= '
|
||
<tr>
|
||
<td colspan="5" style="vertical-align:middle;color:#444;" align="left"><span style="font-weight:bold;font-size:11px" class="productName">'.$this->l('Bon réduction').'</span><br />'.$discount['name'].'</td>
|
||
<td style=" width:70px;vertical-align:middle;color:#444;" align="center">'.($discount['value'] != 0.00 ? '- ' : '').Tools::displayPrice($discount['value'], $currency, false).'</td>
|
||
<td width="70" style="vertical-align:middle;color:#444;"></td>
|
||
</tr>';
|
||
}
|
||
}
|
||
$html .= '</tbody>
|
||
</table>
|
||
<p class="col-md-12" style="font-size:11px; margin:0 0 10px 0;"><i>* Le chiffre de gauche correspond à la quantité remboursée pré-envoi et celui de droite post-envoi</i></p>
|
||
<div class="form-inline text-center">
|
||
<select name="typeReason" class="form-control form-control-sm">
|
||
<option value="0" '.($reason_selected == 0?'selected':'').'>Raison du Remboursement</option>
|
||
<option value="2" '.($reason_selected == 2?'selected':'').'>CLIENT: Rétractaction post-envoi</option>
|
||
<option value="4" '.($reason_selected == 4?'selected':'').'>BBB: Problème SAV</option>
|
||
<option value="5" '.($reason_selected == 5?'selected':'').'>BBB: Produit manquant</option>
|
||
<option value="3" '.($reason_selected == 3?'selected':'').'>BBB: Erreur Achat / Prod</option>
|
||
<option value="6" '.($reason_selected == 6?'selected':'').'>BBB: Erreur Logistique</option>
|
||
<option value="12" '.($reason_selected == 12?'selected':'').'>BBB: Suspicion de fraude</option>
|
||
<option value="9" '.($reason_selected == 9?'selected':'').'>TRANS: Colis détruit</option>
|
||
<option value="10" '.($reason_selected == 10?'selected':'').'>TRANS: Colis perdu</option>
|
||
<option value="7" '.($reason_selected == 7?'selected':'').'>Autre</option>
|
||
</select>
|
||
<div class="checkbox">
|
||
<label style="min-height:0px;">
|
||
<input style="margin:0;" type="checkbox" value="1" name="shippingBack"> Inclure Frais de port
|
||
<Label>
|
||
</div>
|
||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||
<input class="btn btn-primary pull-right" type="submit" name="submitCancelProduct" value="Générer un Remboursement"/>
|
||
</div>
|
||
</div>
|
||
</form>';
|
||
if($order->module && $order->module=="paypal"){
|
||
$html.='
|
||
<form style="margin-top:10px;" action="'.$currentIndex.'&submitCancelProduct=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
|
||
<div class="form-inline text-right">
|
||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||
<button type="submit" class="btn btn-primary" name="submitPayPalRefund">Remboursement Total Paypal <span class="anticon anticon-paypal"></span></button>
|
||
</div>
|
||
</form>';
|
||
}
|
||
$html.='
|
||
</div>
|
||
<div class="clearfix"></div>
|
||
<div class="ln_solid"></div>
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.($order->module ? ($order->module=="paybox"?'<span class="anticon anticon-credit-card"></span> ':'<span class="anticon anticon-paypal"></span> ') : '').' Info Remboursement</h5>
|
||
<div style="padding:10px 20px;background:#efefef;font-size: 12px;" class="">';
|
||
if($order->module && $order->module=="paybox"){
|
||
require_once dirname(__FILE__).'/../../modules/paybox/paybox.php';
|
||
$refundsPaybox = Paybox::getAllRefundbyOrder($order->id);
|
||
if (sizeof($refundsPaybox))
|
||
{
|
||
$html .='<table class="table table-condensed" width="100%;" cellspacing="0" cellpadding="0">';
|
||
foreach ($refundsPaybox as $refund) {
|
||
$html .='
|
||
<tr>
|
||
<td><b>'.(!empty($refund['product_name'])?$refund['product_name']:'Frais de port').'</b></td>
|
||
<td>'. $refund['amount'] / 100 . '€</td>
|
||
</tr>';
|
||
}
|
||
$html .='</table>';
|
||
} else {
|
||
$html .= '<p class="text-center">Pas de remboursement</p>';
|
||
}
|
||
} elseif($order->module && $order->module=="paypal") {
|
||
$messages = Db::getInstance()->ExecuteS('
|
||
SELECT `message`, `date_add`
|
||
FROM `ps_message`
|
||
WHERE `id_order` = '.$order->id.'
|
||
AND (`message` LIKE "%Refund operation%" || `message` LIKE "%Cancel products%")
|
||
ORDER BY `date_add` DESC
|
||
');
|
||
if($messages && !empty($messages)) {
|
||
foreach ($messages as $message) {
|
||
$html .= '<p>('.date('d/m/Y',strtotime($message['message'])).'):<br>'.$message['message'].'</p>';
|
||
}
|
||
}
|
||
|
||
}
|
||
$html .='</div>
|
||
</div>
|
||
</div>
|
||
<div class="ln_solid"></div>
|
||
<div class="row">
|
||
<div class="col-md-6">
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.$this->l('Changer le statut de la commande').'</h5>
|
||
<form style="padding:10px 20px;background:#efefef;" class="text-center center" action="'.$currentIndex.'&submitOrderState=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
|
||
<div class="form-group">
|
||
<select class="form-control" name="id_order_state">';
|
||
$currentStateTab = $order->getCurrentStateFull($cookie->id_lang);
|
||
foreach ($orderStates AS $state){
|
||
$html .= '<option value="'.$state['id_order_state'].'"'.(($state['id_order_state'] == $currentStateTab['id_order_state']) ? ' selected="selected"' : '').'>'.stripslashes($state['name']).'</option>';
|
||
}
|
||
$html .= '
|
||
</select>
|
||
</div>
|
||
<div class="checkbox">
|
||
<label style="min-height:0px;">
|
||
<input type="checkbox" value="1" name="noSendMail" /> Ne pas envoyer de mail
|
||
</label>
|
||
</div>
|
||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||
<input type="submit" name="submitOrderState" value="'.$this->l('Change').'" class="btn btn-primary btn-block" />
|
||
</form>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.$this->l('Changer le statut du retour').'</h5>
|
||
<form style="padding:10px 20px;background:#efefef;" action="'.$currentIndex.'&submitAddorder_return=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
|
||
<input type="hidden" name="id_order" value="'.$orderReturn->id_order.'" />
|
||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||
<input type="hidden" name="id_customer" value="'.$orderReturn->id_customer.'" />
|
||
<div class="form-group">
|
||
<select class="form-control" name="state">';
|
||
$states = OrderReturnState::getOrderReturnStates($cookie->id_lang);
|
||
foreach ($states as $state) {
|
||
$html .= '<option value="'.$state['id_order_return_state'].'"'.($orderReturn->state == $state['id_order_return_state'] ? ' selected="selected"' : '').'>'.$state['name'].'</option>';
|
||
}
|
||
$html .= '</select>
|
||
</div>
|
||
<div class="form-group">
|
||
<input type="submit" class="btn btn-primary btn-block" name="submitAddorder_return" value="Mettre à jour">
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="anticon anticon-box-remove"></span> Renvoyer un colis</h2>
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="form-group">
|
||
<div class="input-group">
|
||
<span class="input-group-addon"><i class="anticon anticon-barcode"></i></span>
|
||
<input type="text" data-table="product-resend" class="form-control input_ean" placeholder="Sélection par EAN..."/>
|
||
</div>
|
||
</div>
|
||
<form action="'.$currentIndex.'&submitResendParcel=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
|
||
<div class="table-responsive">
|
||
<table id="product-resend" class="table table-custombordered">
|
||
<tbody>';
|
||
$id_order_details = array();
|
||
foreach ($order->getProducts() AS $k => $product) {
|
||
$id_order_details[] = (int)($product['id_order_detail']);
|
||
$img_path = '';
|
||
$img = Db::getInstance()->getRow('
|
||
SELECT id_image
|
||
FROM `'._DB_PREFIX_.'image` i
|
||
WHERE i.`id_product` = '.(int)$product['product_id'].'
|
||
AND i.`cover` = 1'
|
||
);
|
||
if (isset($img['id_image']) && !empty($img['id_image'])) {
|
||
$image_obj = new Image((int)$img['id_image']);
|
||
$img_path = (isset($image_obj)?$image_obj->getExistingImgPath():'');
|
||
}
|
||
if (!isset($quantityDisplayed[(int)($product['id_order_detail'])]) OR (int)($product['product_quantity']) > (int)($quantityDisplayed[(int)($product['id_order_detail'])])) {
|
||
$html .='
|
||
<tr>
|
||
<td style="vertical-align:middle;color:#444;font-weight:bold;">
|
||
<a style="display: block;color:#444;" target="_blank" href="index.php?tab=AdminCatalog&id_product='.(int)($product['product_id']).'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" title="'.$this->l('View product').'">
|
||
<img style="display:inline-block;" width="50" src="'.(isset($img_path)?_THEME_PROD_DIR_.$img_path.'-small.jpg':'').'"/><span style="font-weight:bold;display:inline-block;margin-left:5px;vertical-align:middle;">'.mb_strimwidth($product['product_name'], 0, 55, "...").'</span>
|
||
<div class="clearfix"></div>
|
||
</a>
|
||
</td>
|
||
<td width="70" style="vertical-align:middle;color:#444;">
|
||
<input class="form-control" type="number" id="resendQuantity_'.(int)($product['id_order_detail']).'" name="resendQuantity['.(int)($product['id_order_detail']).']" min="0" max="'.$product['product_quantity'].'" data-ean="'.$product['product_ean13'].'" value="0"/>
|
||
</td>
|
||
</tr>';
|
||
}
|
||
}
|
||
$html .='</tbody>
|
||
</table>
|
||
</div>
|
||
<div class="form-grou">
|
||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||
<div class="col-md-4 center">
|
||
<select class="form-control input-sm" name="parcel_carrier">
|
||
<option value="laposte">La poste</option>
|
||
<option value="mondialrelay" disabled>Mondial Relay</option>
|
||
</select>
|
||
</div>
|
||
<div class="col-md-4 center">
|
||
<div class="input-group input-group-sm">
|
||
<input class="form-control input-sm" type="text" name="weight" value="0.24"/>
|
||
<span class="input-group-addon">Kg</span>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="col-md-4 center">
|
||
<input class="btn btn-primary btn-block btn-sm" type="submit" name="submitResendParcel" value="Générer Etiquette" />
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="anticon anticon-box-remove"></span> Historique des colis renvoyés</h2>
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="row">
|
||
<div class="col-md-12">';
|
||
if($parcel_sent && !empty($parcel_sent)) {
|
||
$html .= '
|
||
<table class="table">
|
||
<thead>
|
||
<tr>
|
||
<th>'.$this->l('Produit').'</th>
|
||
<th style="text-align:center;">'.$this->l('Qté').'</th>
|
||
<th style="text-align:center;">'.$this->l('Shipping number').'</th>
|
||
<th style="text-align:center;">'.$this->l('date envoi').'</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>';
|
||
foreach ($parcel_sent as $key => $parcel) {
|
||
$html .= '
|
||
<tr>
|
||
<td>'.$parcel['product_name'].'</td>
|
||
<td style="text-align:center;">'.$parcel['quantity'].'</td>
|
||
<td style="text-align:center;">'.(!empty($carrier->url) ? '<a href="'.str_replace('@', $parcel['shipping_number'], $carrier->url).'" target="_blank">'.$parcel['shipping_number'].'</a>':$parcel['shipping_number']).'</td>
|
||
<td style="text-align:center;">'.date('d/m/Y H:i',strtotime($parcel['date_add'])).'</td>
|
||
</tr>';
|
||
}
|
||
$html .= '</tbody>
|
||
</table>';
|
||
} else {
|
||
$html .='<p class="text-center">Aucun renvoi effectué depuis ce retour</p>';
|
||
}
|
||
$html .='
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-md-12">';
|
||
$parcel_sent_other = Db::getInstance()->ExecuteS('
|
||
SELECT lpr.*, od.`product_name`
|
||
FROM '._DB_PREFIX_.'lapostews_return lpr
|
||
LEFT JOIN '._DB_PREFIX_.'order_detail od ON (lpr.id_order_detail = od.id_order_detail)
|
||
WHERE lpr.id_order_detail IN ('.implode(',', $id_order_details).')
|
||
AND lpr.id_order_return != '.$orderReturn->id.'
|
||
ORDER BY lpr.date_add DESC'
|
||
);
|
||
|
||
if($parcel_sent_other && !empty($parcel_sent_other)) {
|
||
$html .= '
|
||
<p>Envoyé via un autre retour :</p>
|
||
<table class="table">
|
||
<thead>
|
||
<tr>
|
||
<th>'.$this->l('Produit').'</th>
|
||
<th style="text-align:center;">'.$this->l('Qté').'</th>
|
||
<th style="text-align:center;">'.$this->l('Shipping number').'</th>
|
||
<th style="text-align:center;">'.$this->l('date envoi').'</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>';
|
||
foreach ($parcel_sent_other as $key => $parcel) {
|
||
$html .= '
|
||
<tr>
|
||
<td>'.$parcel['product_name'].' (retour <a href="index.php?tab=AdminAntReturnprocess&updateorder_return&id_order_return='.(int)$parcel['id_order_return'].'&token='.Tools::getAdminTokenLite('AdminAntReturnprocess').'" target="_blank">#'.(int)$parcel['id_order_return'].'</a>)</td>
|
||
<td style="text-align:center;">'.$parcel['quantity'].'</td>
|
||
<td style="text-align:center;">'.$parcel['shipping_number'].'</td>
|
||
<td style="text-align:center;">'.date('d/m/Y H:i',strtotime($parcel['date_add'])).'</td>
|
||
</tr>';
|
||
}
|
||
$html .= '</tbody>
|
||
</table>';
|
||
}
|
||
$html .='
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-4">
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="anticon anticon-bubbles2"></span> SAV '.(isset($thread)?'<a href="index.php?tab=AdminCustomerThreads&id_customer_thread='.(int)($thread->id).'&viewcustomer_thread&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'" title=Voir la conversation"> Conversation #'.(int)($thread->id).'</a>':'').'</h2>
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="row">
|
||
<div class="col-md-12">';
|
||
$orderMessages = OrderMessage::getOrderMessages((int)($order->id_lang));
|
||
if(isset($thread)){
|
||
if($thread->id_order == $orderReturn->id_order) {
|
||
$products = Db::getInstance()->ExecuteS('
|
||
SELECT spc.*, pl.`name`
|
||
FROM `'._DB_PREFIX_.'support_product_customerthread` spc
|
||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = spc.`id_product`)
|
||
WHERE spc.`id_customer_thread` = '.(int)$thread->id.'
|
||
AND pl.`id_lang` = 2'
|
||
);
|
||
if($products && !empty($products)) {
|
||
$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('
|
||
SELECT id_image
|
||
FROM `'._DB_PREFIX_.'image` i
|
||
WHERE i.`id_product` = '.(int)$product['id_product'].'
|
||
AND i.`cover` = 1'
|
||
);
|
||
if (isset($img['id_image']) && !empty($img['id_image'])) {
|
||
$image_obj = new Image((int)$img['id_image']);
|
||
$img_path = (isset($image_obj)?$image_obj->getExistingImgPath():'');
|
||
}
|
||
$html .='
|
||
<a style="background:#EFEFEF;padding:5px;display: block;color:#444;" target="_blank" href="index.php?tab=AdminCatalog&id_product='.(int)($product['id_product']).'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" title="'.$this->l('View product').'">
|
||
<img style="display:inline-block;" width="62" src="'.(isset($img_path)?_THEME_PROD_DIR_.$img_path.'-small.jpg':'').'"/><span style="font-weight:bold;display:inline-block;margin-left:5px;width:210px;vertical-align:middle;">'.mb_strimwidth($product['name'], 0, 55, "...").'</span>
|
||
<div class="clearfix"></div>
|
||
</a>';
|
||
}
|
||
}
|
||
}
|
||
if($last_message){
|
||
$html .='<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">
|
||
Dernier Message '.($thread->id_order != $orderReturn->id_order?'<br/><i>(Ne concerne pas cette commande)</i>':'').'
|
||
<a class="pull-right" style="color:#fff;" role="button" data-toggle="collapse" href="#last_message_box" aria-expanded="false" aria-controls="last_message_box">
|
||
<i class="anticon anticon-info"></i>
|
||
</a>
|
||
</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 .='
|
||
<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>
|
||
<div id="last_message_box" class="collapse">
|
||
<p style="padding:5px 20px;background:#efefef;">
|
||
"'.$last_message['message'].'"
|
||
</p>
|
||
</div>';
|
||
} else {
|
||
$html .='
|
||
<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>
|
||
<div id="last_message_box" class="collapse">
|
||
<p style="padding:5px 20px;background:#efefef;">
|
||
"'.$last_message['message'].'"
|
||
</p>
|
||
</div>';
|
||
}
|
||
|
||
$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>';
|
||
}
|
||
$html .='</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="anticon anticon-bubbles4"></span> Message pour cette Commande</h2>
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div><p class="text-center">Laissez un message à votre service client pour cette commande</p></div>';
|
||
if($last_order_message){
|
||
$html .='
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">
|
||
Dernier un message
|
||
<a class="pull-right" style="color:#fff;" role="button" data-toggle="collapse" href="#last_order_message_box" aria-expanded="false" aria-controls="last_order_message_box">
|
||
<i class="anticon anticon-info"></i>
|
||
</a>
|
||
</h5>
|
||
<p class="text-center"><span class="anticon anticon-user-tie"></span> '.$last_order_message['firstname'].' '.$last_order_message['lastname'].' - ('.Tools::displayDate($last_order_message['date_add'], (int)($cookie->id_lang), true).')</p>
|
||
<div class="collapse" id="last_order_message_box">
|
||
<p style="padding:5px 20px;background:#efefef;">
|
||
"'.$last_order_message['message'].'"
|
||
</p>
|
||
</div>';
|
||
}
|
||
$html .='
|
||
<div>
|
||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Laissez 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="orderOverwriteMessage(this, \''.$this->l('Do you want to overwrite your existing 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">
|
||
<textarea rows="5" class="form-control" id="txt_msg" name="message">'.str_replace('\r\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', (int)$order->id_lang)).'</textarea>
|
||
</div>
|
||
<div class="checkbox text-center">
|
||
<label style="min-height:0px;">
|
||
<input type="checkbox" value="1" name="visibility" /> Ne pas montrer au client
|
||
</label>
|
||
</div>
|
||
<div style="text-align: right;">
|
||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||
<input type="hidden" name="id_customer" value="'.$order->id_customer.'" />
|
||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||
<input type="submit" class="btn btn-primary" name="submitOrderMessage" value="'.$this->l('Envoyer').'" style="margin-top:20px;" />
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>';
|
||
|
||
$helper->_js .= '
|
||
<script type="text/javascript">
|
||
$(function() {
|
||
$("#changeAddress").click(function(){
|
||
url = $(this).data("url");
|
||
var p = window.open(url, "Modification Addresse de livraison", "width=720, height=360, resizable=1, scrollbars=1");
|
||
return false;
|
||
});
|
||
$(\'[data-toggle="popover"]\').popover();
|
||
|
||
$("#returnDetailModal").on("show.bs.modal", function (event) {
|
||
var button = $(event.relatedTarget);
|
||
var id_order_detail = button.data("detail");
|
||
var id_instruction = button.data("instruction");
|
||
var id_reason = button.data("reason");
|
||
console.log(button, id_order_detail, id_instruction, id_reason)
|
||
var modal = $(this);
|
||
modal.find(".modal-body input#id_order_detail").val(id_order_detail);
|
||
modal.find(".modal-body select#instruction option[value=\'"+id_instruction+"\']").attr("selected","selected");
|
||
modal.find(".modal-body select#reason option[value=\'"+id_reason+"\']").attr("selected","selected");
|
||
});
|
||
|
||
$(".input_ean").change(function(event){
|
||
table = $(this).data("table");
|
||
input = $("#"+table+" input[data-ean=\'"+$(this).val()+"\']");
|
||
value = input.val();
|
||
max = input.attr("max");
|
||
new_value = parseInt(value) + 1;
|
||
if(new_value <= max) {
|
||
input.val(new_value);
|
||
}
|
||
$(this).val("");
|
||
});
|
||
|
||
});
|
||
</script>
|
||
';
|
||
$html .= $helper->renderScript();
|
||
|
||
echo $html;
|
||
|
||
}
|
||
|
||
public function displaylist()
|
||
{
|
||
global $cookie, $currentIndex;
|
||
|
||
$waiting_return_count = Db::getInstance()->getValue('SELECT COUNT(id_order_return) FROM '._DB_PREFIX_.'order_return WHERE state = 2');
|
||
$received_return_count = Db::getInstance()->getValue('SELECT COUNT(id_order_return) FROM '._DB_PREFIX_.'order_return WHERE state = 3');
|
||
$nonreceived_return_count = Db::getInstance()->getValue('SELECT COUNT(id_order_return) FROM '._DB_PREFIX_.'order_return WHERE state = 6');
|
||
$order_returns = Db::getInstance()->ExecuteS('
|
||
SELECT a.*, orsl.`name`
|
||
FROM '._DB_PREFIX_.'order_return a
|
||
LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)($cookie->id_lang).')
|
||
WHERE a.state != 5 AND a.state != 6
|
||
'.(Tools::getValue('return_order')?' AND a.id_order='.(int)Tools::getValue('return_order'):'').'
|
||
ORDER BY a.date_add DESC'
|
||
);
|
||
|
||
$ended_order_returns = Db::getInstance()->ExecuteS('
|
||
SELECT a.*, orsl.`name`
|
||
FROM '._DB_PREFIX_.'order_return a
|
||
LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)($cookie->id_lang).')
|
||
WHERE a.state = 5
|
||
'.(Tools::getValue('return_order')?' AND a.id_order='.(int)Tools::getValue('return_order'):'').'
|
||
ORDER BY a.date_add DESC'
|
||
);
|
||
|
||
$nonreceived_order_returns = Db::getInstance()->ExecuteS('
|
||
SELECT a.*, orsl.`name`
|
||
FROM '._DB_PREFIX_.'order_return a
|
||
LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)($cookie->id_lang).')
|
||
WHERE a.state = 6
|
||
'.(Tools::getValue('return_order')?' AND a.id_order='.(int)Tools::getValue('return_order'):'').'
|
||
ORDER BY a.date_add DESC'
|
||
);
|
||
|
||
if(Tools::getValue('return_order') && empty($order_returns) && empty($ended_order_returns) && empty($nonreceived_order_returns)) {
|
||
HelperFormBootstrap::displayWarning('Aucun retour trouvé');
|
||
}
|
||
|
||
$colorStates = array(
|
||
1 => "anticon anticon-hour-glass text-orange",
|
||
2 => "anticon anticon-hour-glass text-orange",
|
||
3 => "anticon anticon-box-add text-orange",
|
||
4 => "anticon anticon-cross text-rose",
|
||
5 => "anticon anticon-checkmark text-green-light",
|
||
6 => "anticon anticon-warning text-danger",
|
||
);
|
||
|
||
$helper = new HelperFormBootstrap();
|
||
$helper->_select2 = true;
|
||
$helper->_inputMask = true;
|
||
$html = $helper->renderStyle();
|
||
$html .= '
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="panel">
|
||
<div class="panel-content">
|
||
<a class="btn btn-warning" style="pointer-events: none;" role="button">En attente de colis <span class="badge">'.$waiting_return_count.'</span></a>
|
||
<a class="btn btn-primary" style="pointer-events: none;" role="button">Colis reçu <span class="badge">'.$received_return_count.'</span></a>
|
||
<a class="btn btn-danger" style="pointer-events: none;" role="button">Retour non receptionné <span class="badge">'.$nonreceived_return_count.'</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-md-6">
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="glyphicon glyphicon-barcode"></span> Rechercher par code barre</h2>
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="input-group">
|
||
<input type="text" class="form-control" placeholder="Search for..." id="return_number_input" value="" autocomplete="off">
|
||
<span class="input-group-btn">
|
||
<button class="btn btn-default" type="button"><i class="glyphicon glyphicon-search" onclick="getReturnByNumber();"></i> Search</button>
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="glyphicon glyphicon-tag"></span> Rechercher par commande</h2>
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<form id="return_order_form">
|
||
<div class="input-group">
|
||
<input id="return_order_input" type="text" class="form-control form-control-sm" placeholder="Search for...">
|
||
<span class="input-group-btn">
|
||
<button class="btn btn-default" id="return_order_submit" type="button"><i class="glyphicon glyphicon-search"></i> Search</button>
|
||
</span>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>';
|
||
|
||
if((!Tools::getValue('show_history') && !Tools::getValue('show_non_received')) || Tools::getValue('return_order')) {
|
||
$html.='
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="anticon anticon-loop"></span> Liste des Retours</h2>
|
||
|
||
'.(Tools::getValue('return_order')?
|
||
'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours en cours <span class="'.$colorStates[2].'"></span></a>'
|
||
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default" style="margin-left:5px;">Retours terminés <span class="'.$colorStates[5].'"></span></a>
|
||
<a href="/adm/index.php?tab=AdminAntReturnprocess&show_non_received=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours non reçus <span class="'.$colorStates[6].'"></span></a>'
|
||
).'
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="table-responsive">
|
||
<table class="table table-custombordered">
|
||
<thead>
|
||
<tr>
|
||
<th>'.$this->l('#').'</th>
|
||
<th>'.$this->l('# Order').'</th>
|
||
<th>'.$this->l('# Customer').'</th>
|
||
<th>'.$this->l('Status').'</th>
|
||
<th>'.$this->l('Date').'</th>
|
||
<th class="text-center">'.$this->l('Action').'</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>';
|
||
foreach ($order_returns as $key => $return) {
|
||
$html .= '
|
||
<tr '.(Tools::getValue('return_order') == $return['id_order']? 'class="info"':'').'>
|
||
<td><strong>'.$return['id_order_return'].'</strong></td>
|
||
<td><strong>n° '.$return['id_order'].'</strong></td>
|
||
<td><strong>'.$return['id_customer'].'</strong></td>
|
||
<td><span class="'.$colorStates[$return['state']].'"></span> '.$return['name'].'</td>
|
||
<td>'.date('d/m/Y H:i',strtotime($return['date_add'])).'</td>
|
||
<td align="center">
|
||
<div class="input-group-btn" role="group">
|
||
<a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-edit"></span></a>
|
||
<!--a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&deleteorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-trash"></span></a-->
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
';
|
||
}
|
||
$html .= '</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div>
|
||
</div>';
|
||
}
|
||
|
||
if(Tools::getValue('show_non_received') || Tools::getValue('return_order')) {
|
||
$html.='
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="anticon anticon-loop"></span> Liste des Retours non reçus</h2>
|
||
'.(Tools::getValue('return_order')?
|
||
'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_non_received=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours non reçus <span class="'.$colorStates[6].'"></span></a>'
|
||
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default" style="margin-left:5px;">Retours en cours <span class="'.$colorStates[2].'"></span></a>
|
||
<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours terminés <span class="'.$colorStates[5].'"></span></a>'
|
||
).'
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="table-responsive">
|
||
<table class="table table-custombordered">
|
||
<thead>
|
||
<tr>
|
||
<th>'.$this->l('#').'</th>
|
||
<th>'.$this->l('# Order').'</th>
|
||
<th>'.$this->l('# Customer').'</th>
|
||
<th>'.$this->l('Status').'</th>
|
||
<th>'.$this->l('Date').'</th>
|
||
<th class="text-center">'.$this->l('Action').'</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>';
|
||
foreach ($nonreceived_order_returns as $key => $return) {
|
||
$html .= '
|
||
<tr '.(Tools::getValue('return_order') == $return['id_order']? 'class="info"':'').'>
|
||
<td><strong>'.$return['id_order_return'].'</strong></td>
|
||
<td><strong>n° '.$return['id_order'].'</strong></td>
|
||
<td><strong>'.$return['id_customer'].'</strong></td>
|
||
<td><span class="'.$colorStates[$return['state']].'"></span> '.$return['name'].'</td>
|
||
<td>'.date('d/m/Y H:i',strtotime($return['date_add'])).'</td>
|
||
<td align="center">
|
||
<div class="input-group-btn" role="group">
|
||
<a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-edit"></span></a>
|
||
<!--a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&deleteorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-trash"></span></a-->
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
';
|
||
}
|
||
$html .= '</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div>
|
||
</div>';
|
||
}
|
||
|
||
if(Tools::getValue('show_history') || Tools::getValue('return_order')) {
|
||
$html.='
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="panel">
|
||
<div class="panel-title">
|
||
<h2><span class="anticon anticon-loop"></span> Retours Terminés</h2>
|
||
'.(Tools::getValue('return_order')?
|
||
'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours terminés <span class="'.$colorStates[5].'"></span></a>'
|
||
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default" style="margin-left:5px;">Retours en cours <span class="'.$colorStates[2].'"></span></a>
|
||
<a href="/adm/index.php?tab=AdminAntReturnprocess&show_non_received=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours non reçus <span class="'.$colorStates[6].'"></span></a>'
|
||
).'
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="panel-content">
|
||
<div class="table-responsive">
|
||
<table class="table table-custombordered">
|
||
<thead>
|
||
<tr>
|
||
<th>'.$this->l('#').'</th>
|
||
<th>'.$this->l('# Order').'</th>
|
||
<th>'.$this->l('# Customer').'</th>
|
||
<th>'.$this->l('Status').'</th>
|
||
<th>'.$this->l('Date').'</th>
|
||
<th class="text-center">'.$this->l('Action').'</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>';
|
||
foreach ($ended_order_returns as $key => $return) {
|
||
$html .= '
|
||
<tr '.(Tools::getValue('return_order') == $return['id_order']? 'class="info"':'').'>
|
||
<td><strong>'.$return['id_order_return'].'</strong></td>
|
||
<td><strong>n° '.$return['id_order'].'</strong></td>
|
||
<td><strong>'.$return['id_customer'].'</strong></td>
|
||
<td><span class="'.$colorStates[$return['state']].'"></span> '.$return['name'].'</td>
|
||
<td>'.date('d/m/Y H:i',strtotime($return['date_add'])).'</td>
|
||
<td align="center">
|
||
<div class="input-group-btn" role="group">
|
||
<a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-edit"></span></a>
|
||
<!--a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&deleteorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-trash"></span></a-->
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
';
|
||
}
|
||
$html .= '</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div>';
|
||
}
|
||
$html .= '<div class="clearfix"></div>';
|
||
|
||
$helper->_js .= '
|
||
<script type="text/javascript">
|
||
function getReturnByNumber() {
|
||
var val = $("#return_number_input").val().trim();
|
||
if(val != "" && val.length == 15) {
|
||
document.location.href = "/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'&return_number=" + val;
|
||
}
|
||
}
|
||
function getReturnByOrder() {
|
||
var val = $("#return_order_input").val().trim();
|
||
if(val != "") {
|
||
document.location.href = "/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'&return_order=" + val;
|
||
}
|
||
}
|
||
$(function() {
|
||
$("#return_number_input").bind("keydown", function(e) {
|
||
if(e.which == 13) {
|
||
getReturnByNumber();
|
||
return false;
|
||
}
|
||
});
|
||
$("#return_order_submit").click(function(){
|
||
getReturnByOrder();
|
||
return false;
|
||
});
|
||
$("#return_order_form").submit(function(){
|
||
getReturnByOrder();
|
||
return false;
|
||
});
|
||
});
|
||
</script>';
|
||
$html .= $helper->renderScript();
|
||
|
||
echo $html;
|
||
}
|
||
|
||
public function getOrderDetail($cart, $id_lang, $order){
|
||
if(Db::getInstance()->getValue('
|
||
SELECT `id_carrier`
|
||
FROM `'._DB_PREFIX_.'carrier`
|
||
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
|
||
AND `name` LIKE "%colissimo%"
|
||
')) {
|
||
$socol = Db::getInstance()->getRow('
|
||
SELECT *
|
||
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
|
||
WHERE `id_cart` = '.(int) $cart->id.'
|
||
AND `cecountry` IN ("FR","BE","ES")
|
||
AND (`pradress1`!= "" OR `pradress2`!= "" OR `pradress3`!= "" OR `pradress4`!= "")
|
||
');
|
||
if($socol && (int)$cart->id_carrier != (int)Configuration::get('ANT_CARRIER_DOM')) {
|
||
$order_address = nl2br(preg_replace("/(\r\n){2,}/", "\r\n", implode("\r\n", array(
|
||
$socol['cefirstname'].' '.$socol['cename'],
|
||
$socol['cecompanyname'],
|
||
$socol['prname'],
|
||
$socol['prcompladress'],
|
||
$socol['pradress1'],
|
||
$socol['pradress2'],
|
||
$socol['pradress3'],
|
||
$socol['pradress4'],
|
||
$socol['przipcode'].' '.$socol['prtown'],
|
||
$socol['cecountry'],
|
||
$socol['cephonenumber'],
|
||
!empty($socol['cedoorcode1'])? 'Code porte 1 : '.$socol['cedoorcode1']: '',
|
||
!empty($socol['cedoorcode2'])? 'Code porte 2 : '.$socol['cedoorcode2']: '',
|
||
$socol['cedeliveryinformation'],
|
||
))));
|
||
} else {
|
||
$order_address = nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_delivery)));
|
||
}
|
||
} elseif(Db::getInstance()->getValue('
|
||
SELECT COUNT(*)
|
||
FROM `'._DB_PREFIX_.'mr_method`
|
||
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
|
||
AND `MR_Selected_Num` IS NOT NULL
|
||
')) {
|
||
$mr = Db::getInstance()->getRow('
|
||
SELECT mr_s.*
|
||
FROM `' . _DB_PREFIX_ . 'mr_selected` mr_s
|
||
WHERE `id_cart` = ' . (int) $cart->id . '
|
||
');
|
||
if($mr) {
|
||
$order_address = nl2br(preg_replace("/(\r\n){2,}/", "\r\n", implode("\r\n", array(
|
||
$mr['MR_Selected_LgAdr1'],
|
||
$mr['MR_Selected_LgAdr2'],
|
||
$mr['MR_Selected_LgAdr3'] . ' ' . $mr['MR_Selected_LgAdr4'],
|
||
$mr['MR_Selected_CP'] . ' ' . $mr['MR_Selected_Ville'],
|
||
'FRANCE',
|
||
))));
|
||
} else {
|
||
$order_address = nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_delivery)));
|
||
}
|
||
} else {
|
||
$order_address = nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_delivery)));
|
||
}
|
||
|
||
$carrier_name = Db::getInstance()->getValue('
|
||
SELECT `name`
|
||
FROM `'._DB_PREFIX_.'carrier`
|
||
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
|
||
');
|
||
|
||
return array(
|
||
'order_invoice_address' => nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_invoice))),
|
||
'order_address' => $order_address,
|
||
'carrier_name' => $carrier_name,
|
||
);
|
||
}
|
||
}
|