128 lines
4.9 KiB
PHP
128 lines
4.9 KiB
PHP
|
<?php
|
||
|
class OrderReturnController extends OrderReturnControllerCore {
|
||
|
public function setMedia() {
|
||
|
parent::setMedia();
|
||
|
|
||
|
global $css_files;
|
||
|
$css_files = array_slice($css_files, 0, 1);
|
||
|
|
||
|
if (Tools::getValue('ajax') != 'true') {
|
||
|
Tools::addJS(_THEME_JS_DIR_.'history.js');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function preProcess() {
|
||
|
// This function is rewritten and splitted to support non-ajax requests
|
||
|
|
||
|
global $page_name;
|
||
|
if(!isset($this->php_self)) {
|
||
|
$this->php_self = strtolower(basename($_SERVER['PHP_SELF']));
|
||
|
}
|
||
|
if($this->php_self == '404.php') {
|
||
|
$page_name = 'page-404';
|
||
|
} else {
|
||
|
if(preg_match('#^'.__PS_BASE_URI__.'modules/([a-zA-Z0-9_-]+?)/([^?]*)(\?(.*))?$#', strtolower($_SERVER['REQUEST_URI']), $m)) {
|
||
|
$page_name = 'module-'.$m[1].'-'.str_replace(array('.php', '/'), array('', '-'), $m[2]);
|
||
|
} else {
|
||
|
$page_name = preg_replace('/\.php$/', '', $this->php_self);
|
||
|
}
|
||
|
}
|
||
|
self::$smarty->assign(array('page_name' => $page_name));
|
||
|
|
||
|
$displayLeft = array(
|
||
|
'page-404', 'address', 'addresses', 'authentication', 'best-sales',
|
||
|
'breadcrumb', 'category', 'category-cms-tree-branch',
|
||
|
'category-tree-branch', 'cms', 'contact-form', 'discount',
|
||
|
'errors', 'footer', 'guest-tracking', 'header', 'history',
|
||
|
'identity', 'index', 'maintenance', 'manufacturer',
|
||
|
'manufacturer-list', 'my-account', 'new-products', 'order',
|
||
|
'order-address', 'order-carrier', 'order-confirmation',
|
||
|
'order-detail', 'order-follow', 'order-opc',
|
||
|
'order-opc-new-account', 'order-payment', 'order-return',
|
||
|
'order-slip', 'order-steps', 'pagination', 'password', 'payment',
|
||
|
'prices-drop', 'product', 'product-compare', 'product-list',
|
||
|
'products-comparison', 'product-sort', 'restricted-country',
|
||
|
'scenes', 'search', 'shopping-cart', 'shopping-cart-product-line',
|
||
|
'sitemap', 'store_infos', 'stores', 'supplier', 'supplier-list',
|
||
|
'module-privatesales-salechange', 'module-invite-invite-program',
|
||
|
'module-referralprogram-referral-program', 'module-cheque-payment',
|
||
|
'module-bankwire-payment', 'module-invite-invite-rules',
|
||
|
);
|
||
|
if($page_name == 'index') {
|
||
|
global $cookie;
|
||
|
if($cookie->isLogged()) {
|
||
|
$displayLeft[] = 'index';
|
||
|
}
|
||
|
}
|
||
|
$displayRight = array(
|
||
|
'page-404', 'address', 'addresses', 'authentication', 'best-sales',
|
||
|
'breadcrumb', 'category', 'category-cms-tree-branch',
|
||
|
'category-tree-branch', 'cms', 'contact-form', 'discount',
|
||
|
'errors', 'footer', 'guest-tracking', 'header', 'history',
|
||
|
'identity', 'index', 'maintenance', 'manufacturer',
|
||
|
'manufacturer-list', 'my-account', 'new-products', 'order',
|
||
|
'order-address', 'order-carrier', 'order-confirmation',
|
||
|
'order-detail', 'order-follow', 'order-opc',
|
||
|
'order-opc-new-account', 'order-payment', 'order-return',
|
||
|
'order-slip', 'order-steps', 'pagination', 'password', 'payment',
|
||
|
'prices-drop', 'product', 'product-compare', 'product-list',
|
||
|
'products-comparison', 'product-sort', 'restricted-country',
|
||
|
'scenes', 'search', 'shopping-cart', 'shopping-cart-product-line',
|
||
|
'sitemap', 'store_infos', 'stores', 'supplier', 'supplier-list',
|
||
|
'module-privatesales-salechange', 'module-invite-invite-program',
|
||
|
'module-referralprogram-referral-program', 'module-cheque-payment',
|
||
|
'module-bankwire-payment', 'module-invite-invite-rules',
|
||
|
);
|
||
|
|
||
|
$countCols = count(array_keys($displayLeft + $displayRight, $page_name));
|
||
|
|
||
|
$bodyClass = 'singleCol';
|
||
|
if($countCols == 1) {
|
||
|
$bodyClass = 'doubleCol';
|
||
|
} elseif($countCols == 2) {
|
||
|
$bodyClass = 'tripleCol';
|
||
|
}
|
||
|
|
||
|
self::$smarty->assign(array(
|
||
|
'displayLeft' => $displayLeft,
|
||
|
'displayRight' => $displayRight,
|
||
|
'bodyClass' => $bodyClass,
|
||
|
));
|
||
|
|
||
|
Module::hookExec('preprocess');
|
||
|
}
|
||
|
|
||
|
public function process() {
|
||
|
if(!isset($_GET['id_order_return']) OR !Validate::isUnsignedId($_GET['id_order_return'])) {
|
||
|
$this->errors[] = Tools::displayError('Order ID required');
|
||
|
} else {
|
||
|
$orderRet = new OrderReturn((int)($_GET['id_order_return']));
|
||
|
if(Validate::isLoadedObject($orderRet) AND $orderRet->id_customer == self::$cookie->id_customer) {
|
||
|
$order = new Order((int)($orderRet->id_order));
|
||
|
if (Validate::isLoadedObject($order)) {
|
||
|
$state = new OrderReturnState((int)($orderRet->state));
|
||
|
self::$smarty->assign(array(
|
||
|
'orderRet' => $orderRet,
|
||
|
'order' => $order,
|
||
|
'state_name' => $state->name[(int)(self::$cookie->id_lang)],
|
||
|
'return_allowed' => false,
|
||
|
'products' => OrderReturn::getOrdersReturnProducts((int)($orderRet->id), $order),
|
||
|
'returnedCustomizations' => OrderReturn::getReturnedCustomizedProducts((int)($orderRet->id_order)),
|
||
|
'customizedDatas' => Product::getAllCustomizedDatas((int)($order->id_cart))
|
||
|
));
|
||
|
} else {
|
||
|
$this->errors[] = Tools::displayError('Cannot find this order return');
|
||
|
}
|
||
|
} else {
|
||
|
$this->errors[] = Tools::displayError('Cannot find this order return');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
self::$smarty->assign(array(
|
||
|
'errors' => $this->errors,
|
||
|
'nbdaysreturn' => (int)(Configuration::get('PS_ORDER_RETURN_NB_DAYS'))
|
||
|
));
|
||
|
}
|
||
|
}
|
||
|
|