// Stock: updated controllers

This commit is contained in:
bMancone
2011-11-30 10:32:55 +00:00
parent 925d795721
commit 57e42fc2b7
4 changed files with 108 additions and 1 deletions
+1
View File
@@ -213,6 +213,7 @@ form#product_form h4 { font-size:18px; font-weight:normal;}
.filter-stock { background-color:#ebedf4; border:1px solid #c2c4d9; margin-bottom:15px; padding:10px; display:block; min-height:25px;}
.filter-stock #stock_cover {float:left; margin-right:30px;}
.filter-stock #stock_instant_state {float:left; margin-right:30px;}
.filter-stock #supply_orders {float:left; margin-right:30px;}
.filter-stock label {width:auto;}
.filter-stock .select-filter { float:left;}
.filter-stock .button-filter { float:right;}
@@ -0,0 +1,46 @@
{*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file="helper/list/list_header.tpl"}
{block name=override_header}
{if isset($warehouses) && count($warehouses) > 0 && isset($filter_status)}
<div class="filter-stock">
<form id="supply_orders" type="get">
<input type="hidden" name="controller" value="AdminSupplyOrders" />
<input type="hidden" name="token" value="{$token}" />
<label for="filter_status">{l s='Choose not to display completed/canceled orders and filter by warehouse:'}</label>
<input type="checkbox" name="filter_status" class="noborder" onChange="$(this).parent().submit();" {if $filter_status == 1}value="on" checked{/if}></input>
<select name="id_warehouse" onChange="$(this).parent().submit();">
{foreach from=$warehouses key=k item=i}
<option {if $i.id_warehouse == $current_warehouse} selected="selected"{/if} value="{$i.id_warehouse}">{$i.name}</option>
{/foreach}
</select>
</form>
</div>
{/if}
{/block}
@@ -40,7 +40,6 @@ class AdminStockMvtControllerCore extends AdminController
$this->list_no_link = true;
$this->displayInformation($this->l('This interface allows you to display the stock movements for a selected warehouse.').'<br />');
$this->displayInformation($this->l('Also, it allows you to add and edit your own stock movement labels.'));
$this->fieldsDisplay = array(
'product_reference' => array(
@@ -30,6 +30,12 @@
*/
class AdminSupplyOrdersControllerCore extends AdminController
{
/*
* @var array List of warehouses
*/
private $warehouses;
public function __construct()
{
$this->context = Context::getContext();
@@ -100,6 +106,11 @@ class AdminSupplyOrdersControllerCore extends AdminController
),
);
// gets the list of warehouses available
$this->warehouses = Warehouse::getWarehouses(true);
// gets the final list of warehouses
array_unshift($this->warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
parent::__construct();
}
@@ -322,6 +333,13 @@ class AdminSupplyOrdersControllerCore extends AdminController
public function initList()
{
$this->displayInformation($this->l('This interface allows you to manage supply orders.').'<br />');
$this->displayInformation($this->l('Also, you can create templates that you can later use to generate actual orders.').'<br />');
// assigns warehouses
$this->tpl_list_vars['warehouses'] = $this->warehouses;
$this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouse();
$this->tpl_list_vars['filter_status'] = $this->getFilterStatus();
// access
if (!($this->tabAccess['add'] === '1'))
@@ -350,10 +368,17 @@ class AdminSupplyOrdersControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = a.id_warehouse)';
$this->_where = ' AND a.is_template = 0';
if ($this->getCurrentWarehouse() != -1)
$this->_where .= ' AND a.id_warehouse = '.$this->getCurrentWarehouse();
if ($this->getFilterStatus() != 0)
$this->_where .= ' AND st.enclosed != 1';
$first_list = parent::initList();
// second list : templates
$second_list = null;
unset($this->tpl_list_vars['warehouses']);
unset($this->tpl_list_vars['current_warehouse']);
unset($this->tpl_list_vars['filter_status']);
// unsets actions
$this->actions = array();
@@ -367,6 +392,8 @@ class AdminSupplyOrdersControllerCore extends AdminController
// adds filter, to gets only templates
unset($this->_where);
$this->_where = ' AND a.is_template = 1';
if ($this->getCurrentWarehouse() != -1)
$this->_where .= ' AND a.id_warehouse = '.$this->getCurrentWarehouse();
// re-defines toolbar & buttons
$this->toolbar_title = $this->l('Stock : Supply orders templates');
@@ -1792,4 +1819,38 @@ class AdminSupplyOrdersControllerCore extends AdminController
$redirect = self::$currentIndex.'&token='.$token;
$this->redirect_after = $redirect.'&conf=19';
}
/**
* Gets the current warehouse used
*
* @return int id_warehouse
*/
private function getCurrentWarehouse()
{
static $warehouse = 0;
if ($warehouse == 0)
{
$warehouse = -1; // all warehouses
if ((int)Tools::getValue('id_warehouse'))
$warehouse = (int)Tools::getValue('id_warehouse');
}
return $warehouse;
}
/**
* Gets the current warehouse used
*
* @return int id_warehouse
*/
private function getFilterStatus()
{
static $status = 0;
$status = 0;
if (Tools::getValue('filter_status') === 'on')
$status = 1;
return $status;
}
}