[-] Classes : fixed bug #PSTEST-549 - Clean useless code

[-] BO : fixed bug on sorting feature on AdminOrdersController
// Clean code
This commit is contained in:
aFolletete
2012-01-31 14:34:59 +00:00
parent 3d119fb9dd
commit 4e4d2829fe
2 changed files with 20 additions and 7 deletions

View File

@@ -1956,9 +1956,23 @@ class AdminControllerCore extends Controller
throw new PrestaShopException(sprintf('Table name %s is invalid:', $this->table));
if (empty($order_by))
$order_by = $this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : $this->_defaultOrderBy;
{
if ($this->context->cookie->{$this->table.'Orderby'})
$order_by = $this->context->cookie->{$this->table.'Orderby'};
elseif ($this->_orderBy)
$order_by = $this->_orderBy;
else
$order_by = $this->_defaultOrderBy;
}
if (empty($order_way))
$order_way = $this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderway') : $this->_defaultOrderWay;
{
if ($this->context->cookie->{$this->table.'Orderway'})
$order_way = $this->context->cookie->{$this->table.'Orderway'};
elseif ($this->_orderWay)
$order_way = $this->_orderWay;
else
$order_way = $this->_defaultOrderWay;
}
$limit = (int)Tools::getValue('pagination', $limit);
$this->context->cookie->{$this->table.'_pagination'} = $limit;

View File

@@ -45,8 +45,7 @@ class AdminOrdersControllerCore extends AdminController
CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
osl.`name` AS `osname`,
os.`color`,
IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
(SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number';
IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new';
$this->_join = '
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
@@ -54,8 +53,8 @@ class AdminOrdersControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';
$this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)';
$this->_orderBy = '`id_order`';
$this->_orderWay = 'DESC'; // FIXME
$this->_orderBy = 'id_order';
$this->_orderWay = 'DESC';
$statuses_array = array();
$statuses = OrderState::getOrderStates((int)$this->context->language->id);
@@ -175,7 +174,7 @@ class AdminOrdersControllerCore extends AdminController
public function postProcess()
{
// If id_order is sent, we instanciate a new Order object
if (Tools::isSubmit('id_order'))
if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0)
{
$order = new Order(Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order))