// Improved filters
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13886 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -190,8 +190,13 @@ class AdminStockCoverControllerCore extends AdminController
|
||||
$this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations, SUM(s.usable_quantity) as stock';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.id_product = a.id_product)
|
||||
INNER JOIN `'._DB_PREFIX_.'stock` s ON (s.id_product = a.id_product)';
|
||||
|
||||
self::$currentIndex .= '&coverage_period='.(int)$this->getCurrentCoveragePeriod().'&warn_days='.(int)$this->getCurrentWarning();
|
||||
if ($this->getCurrentCoverageWarehouse() != -1)
|
||||
$this->_where .= ' AND s.id_warehouse = '.$this->getCurrentCoverageWarehouse();
|
||||
{
|
||||
$this->_where .= ' AND s.id_warehouse = '.(int)$this->getCurrentCoverageWarehouse();
|
||||
self::$currentIndex .= '&id_warehouse='.(int)$this->getCurrentCoverageWarehouse();
|
||||
}
|
||||
|
||||
// Hack for multi shop ..
|
||||
$this->_where .= ' AND b.id_shop = 1';
|
||||
|
||||
@@ -71,7 +71,7 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
'valuation' => array(
|
||||
'title' => $this->l('Valuation'),
|
||||
'width' => 150,
|
||||
'orderby' => false,
|
||||
'orderby' => true,
|
||||
'search' => false,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
@@ -92,7 +92,7 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
'real_quantity' => array(
|
||||
'title' => $this->l('Real quantity'),
|
||||
'width' => 80,
|
||||
'orderby' => false,
|
||||
'orderby' => true,
|
||||
'search' => false,
|
||||
'hint' => $this->l('Pysical qty (usable) - Clients orders + Supply Orders'),
|
||||
),
|
||||
@@ -135,7 +135,10 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
)';
|
||||
|
||||
if ($this->getCurrentCoverageWarehouse() != -1)
|
||||
{
|
||||
$this->_where .= ' AND a.id_warehouse = '.$this->getCurrentCoverageWarehouse();
|
||||
self::$currentIndex .= '&id_warehouse='.(int)$this->getCurrentCoverageWarehouse();
|
||||
}
|
||||
|
||||
// toolbar btn
|
||||
$this->toolbar_btn = array();
|
||||
@@ -181,6 +184,19 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
if (Tools::isSubmit('csv') && (int)Tools::getValue('id_warehouse') != -1)
|
||||
$limit = false;
|
||||
|
||||
$order_by_valuation = false;
|
||||
$order_by_real_quantity = false;
|
||||
if ($this->context->cookie->{$this->table.'Orderby'} == 'valuation')
|
||||
{
|
||||
unset($this->context->cookie->{$this->table.'Orderby'});
|
||||
$order_by_valuation = true;
|
||||
}
|
||||
else if ($this->context->cookie->{$this->table.'Orderby'} == 'real_quantity')
|
||||
{
|
||||
unset($this->context->cookie->{$this->table.'Orderby'});
|
||||
$order_by_real_quantity = true;
|
||||
}
|
||||
|
||||
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
|
||||
|
||||
$nb_items = count($this->_list);
|
||||
@@ -201,8 +217,10 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
$query->select('SUM(price_te * physical_quantity) as valuation');
|
||||
$query->from('stock');
|
||||
$query->where('id_product = '.(int)$item['id_product'].' AND id_product_attribute = '.(int)$item['id_product_attribute']);
|
||||
|
||||
if ($this->getCurrentCoverageWarehouse() != -1)
|
||||
$query->where('id_warehouse = '.(int)$this->getCurrentCoverageWarehouse());
|
||||
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
|
||||
|
||||
$item['physical_quantity'] = $res['physical_quantity'];
|
||||
@@ -220,6 +238,39 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
else
|
||||
$item['valuation'] = $res['valuation'];
|
||||
}
|
||||
|
||||
if ($this->getCurrentCoverageWarehouse() != -1 && $order_by_valuation)
|
||||
usort($this->_list, array($this, 'valuationCmp'));
|
||||
else if ($order_by_real_quantity)
|
||||
usort($this->_list, array($this, 'realQuantityCmp'));
|
||||
}
|
||||
|
||||
/**
|
||||
* CMP
|
||||
*
|
||||
* @param array $n
|
||||
* @param array $m
|
||||
*/
|
||||
public function valuationCmp($n, $m)
|
||||
{
|
||||
if ($this->context->cookie->{$this->table.'Orderway'} == 'desc')
|
||||
return $n['valuation'] > $m['valuation'];
|
||||
else
|
||||
return $n['valuation'] < $m['valuation'];
|
||||
}
|
||||
|
||||
/**
|
||||
* CMP
|
||||
*
|
||||
* @param array $n
|
||||
* @param array $m
|
||||
*/
|
||||
public function realQuantityCmp($n, $m)
|
||||
{
|
||||
if ($this->context->cookie->{$this->table.'Orderway'} == 'desc')
|
||||
return $n['real_quantity'] > $m['real_quantity'];
|
||||
else
|
||||
return $n['real_quantity'] < $m['real_quantity'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -158,9 +158,12 @@ class AdminStockMvtControllerCore extends AdminController
|
||||
$this->_group = 'GROUP BY a.id_stock_mvt';
|
||||
|
||||
// overrides where depending on the warehouse
|
||||
$id_warehouse = $this->getCurrentWarehouseId();
|
||||
$id_warehouse = (int)$this->getCurrentWarehouseId();
|
||||
if ($id_warehouse > 0)
|
||||
{
|
||||
$this->_where = ' AND w.id_warehouse = '.$id_warehouse;
|
||||
self::$currentIndex .= '&id_warehouse='.$id_warehouse;
|
||||
}
|
||||
|
||||
// sets the current warehouse
|
||||
$this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId();
|
||||
|
||||
@@ -450,9 +450,16 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
$this->_where = ' AND a.is_template = 0';
|
||||
|
||||
if ($this->getCurrentWarehouse() != -1)
|
||||
{
|
||||
$this->_where .= ' AND a.id_warehouse = '.$this->getCurrentWarehouse();
|
||||
self::$currentIndex .= '&id_warehouse='.(int)$this->getCurrentWarehouse();
|
||||
}
|
||||
|
||||
if ($this->getFilterStatus() != 0)
|
||||
{
|
||||
$this->_where .= ' AND st.enclosed != 1';
|
||||
self::$currentIndex .= '&filter_status=on';
|
||||
}
|
||||
$first_list = parent::renderList();
|
||||
|
||||
if (Tools::isSubmit('csv_orders') || Tools::isSubmit('csv_orders_details') || Tools::isSubmit('csv_order_details'))
|
||||
|
||||
Reference in New Issue
Block a user