// #PSFV-94 : fix toolbar and leadin integration on all stock controllers + bugs fix

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9932 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
dSevere
2011-11-07 15:18:47 +00:00
parent 55166aefa1
commit be6473f82d
11 changed files with 67 additions and 158 deletions
@@ -36,4 +36,4 @@
</tr>
</table>
<input type="hidden" name="token" value="{$token}" />
</form>
</form>
@@ -59,6 +59,8 @@
{/if}{* End if simple_header *}
<a name="{$table}">&nbsp;</a>
{if $show_toolbar}
<div class="toolbar-placeholder">
<div class="toolbarBox {if $toolbar_fix}toolbarHead{/if}">
@@ -74,7 +76,7 @@
{/if}
<div class="leadin">{block name="leadin"}{/block}</div>
<a name="{$table}">&nbsp;</a>
<form method="post" action="{$action}" class="form">
<input type="hidden" id="submitFilter{$table}" name="submitFilter{$table}" value="0"/>
@@ -1,51 +0,0 @@
{*
* 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
*}
<form id="stock_cover" type="get">
<input type="hidden" name="controller" value="AdminStockCover" />
<input type="hidden" name="token" value="{$token}" />
{if count($stock_cover_periods) > 1}
<div id="stock_cover_form_period">
<label for="coverage_period">{l s="Select a period:"}</label>
<select name="coverage_period" onChange="$(this).parent().parent().submit();">
{foreach from=$stock_cover_periods key=k item=i}
<option {if $i == $stock_cover_cur_period} selected="selected"{/if} value="{$i}">{$k}</option>
{/foreach}
</select>
</div>
{/if}
{if count($stock_cover_warehouses) > 1}
<div id="stock_cover_form_warehouse">
<label for="coverage_warehouse">{l s="Select a warehouse:"}</label>
<select name="coverage_warehouse" onChange="$(this).parent().parent().submit();">
{foreach from=$stock_cover_warehouses key=k item=i}
<option {if $i.id_warehouse == $stock_cover_cur_warehouse} selected="selected"{/if} value="{$i.id_warehouse}">{$i.name}</option>
{/foreach}
</select>
</div>
{/if}
</form>
{$content}
@@ -1,39 +0,0 @@
{*
* 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
*}
{if count($list_warehouses) > 1}
<form type="get">
<label for="wareouse">{l s="Select a warehouse:"}</label>
<input type="hidden" name="controller" value="AdminStockInstantState" />
<input type="hidden" name="token" value="{$token}" />
<select name="warehouse" onchange="$(this).parent().submit();">
{foreach $list_warehouses as $warehouse}
<option {if $warehouse.id_warehouse == $current_warehouse}selected="selected"{/if} value="{$warehouse.id_warehouse}">{$warehouse.name}</option>
{/foreach}
</select>
</form>
{/if}
{$content}
@@ -1,39 +0,0 @@
{*
* 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: 9556 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{if count($list_warehouses) > 1}
<form type="get" onchange="submit();">
<label for="warehouse">{l s="Select a warehouse:"}</label>
<input type="hidden" name="controller" value="AdminStockMvt" />
<input type="hidden" name="token" value="{$token}" />
<select name="warehouse">
{foreach $list_warehouses as $warehouse}
<option {if $warehouse.id_warehouse == $current_warehouse}selected="selected"{/if} value="{$warehouse.id_warehouse}">{$warehouse.name}</option>
{/foreach}
</select>
</form>
{/if}
{$content}
@@ -147,10 +147,10 @@ class AdminStockCoverControllerCore extends AdminController
if ($this->getCurrentCoverageWarehouse() != -1)
$this->_where .= ' AND s.id_warehouse = '.$this->getCurrentCoverageWarehouse();
$this->context->smarty->assign('stock_cover_periods', $this->stock_cover_periods);
$this->context->smarty->assign('stock_cover_cur_period', $this->getCurrentCoveragePeriod());
$this->context->smarty->assign('stock_cover_warehouses', $this->stock_cover_warehouses);
$this->context->smarty->assign('stock_cover_cur_warehouse', $this->getCurrentCoverageWarehouse());
$this->tpl_list_vars['stock_cover_periods'] = $this->stock_cover_periods;
$this->tpl_list_vars['stock_cover_cur_period'] = $this->getCurrentCoveragePeriod();
$this->tpl_list_vars['stock_cover_warehouses'] = $this->stock_cover_warehouses;
$this->tpl_list_vars['stock_cover_cur_warehouse'] = $this->getCurrentCoverageWarehouse();
$this->displayInformation(
$this->l('Considering the coverage period choosen and the quantity of products/combinations that you sold,
@@ -96,8 +96,8 @@ class AdminStockInstantStateControllerCore extends AdminController
//no link on list rows
$this->list_no_link = true;
$this->context->smarty->assign('list_warehouses', Warehouse::getWarehouseList(true));
$this->context->smarty->assign('current_warehouse', $this->getCurrentWarehouseId());
$this->tpl_list_vars['list_warehouses'] = Warehouse::getWarehouseList(true);
$this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId();
return parent::initList();
}
@@ -86,6 +86,8 @@ class AdminStockManagementControllerCore extends AdminController
// no link on list rows
$this->list_no_link = true;
$this->toolbar_btn = array();
$this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.id_product = a.id_product)';
@@ -689,6 +691,19 @@ class AdminStockManagementControllerCore extends AdminController
'href' => '#',
'desc' => $this->l('Save')
);
// Default cancel button - like old back link
if (!isset($this->no_back) || $this->no_back == false)
{
$back = Tools::safeOutput(Tools::getValue('back', ''));
if (empty($back))
$back = self::$currentIndex.'&token='.$this->token;
$this->toolbar_btn['cancel'] = array(
'href' => $back,
'desc' => $this->l('Cancel')
);
}
break;
default:
@@ -705,13 +720,22 @@ class AdminStockManagementControllerCore extends AdminController
parent::init();
if (Tools::isSubmit('addstock'))
{
$this->display = 'addstock';
$this->toolbar_title = $this->l('Stock : Add product');
}
if (Tools::isSubmit('removestock'))
{
$this->display = 'removestock';
$this->toolbar_title = $this->l('Stock : Remove product');
}
if (Tools::isSubmit('transferstock'))
{
$this->display = 'transferstock';
$this->toolbar_title = $this->l('Stock : Transfer product');
}
}
/**
@@ -760,6 +784,8 @@ class AdminStockManagementControllerCore extends AdminController
// Render list
$helper = new HelperList();
$helper->bulk_actions = array();
$helper->toolbar_fix = $this->toolbar_fix;
$helper->show_toolbar = false;
$helper->actions = $this->actions;
$helper->list_skip_actions = $this->list_skip_actions;
$helper->no_link = true;
@@ -928,10 +954,8 @@ class AdminStockManagementControllerCore extends AdminController
if (file_exists($this->context->smarty->template_dir.'/'.$this->tpl_folder.'form.tpl'))
$helper->tpl = $this->tpl_folder.'form.tpl';
$this->setHelperDisplay($helper);
$helper->submit_action = $this->display;
$helper->toolbar_btn = $this->toolbar_btn;
$helper->currentIndex = self::$currentIndex;
$helper->token = $this->token;
$helper->id = null; // no display standard hidden field in the form
$helper->languages = $this->_languages;
$helper->default_form_language = $this->default_form_language;
@@ -95,7 +95,7 @@ class AdminStockMvtControllerCore extends AdminController
)
);
$this->context->smarty->assign('list_warehouses', array());
$this->tpl_list_vars['list_warehouses'] = array();
parent::__construct();
}
@@ -106,6 +106,8 @@ class AdminStockMvtControllerCore extends AdminController
*/
public function initForm()
{
$this->toolbar_title = $this->l('Stock : Add Stock movement reason');
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Stock Movement Reason'),
@@ -176,30 +178,27 @@ class AdminStockMvtControllerCore extends AdminController
$this->addRowActionSkipList('edit', array(6, 7));
$this->addRowActionSkipList('delete', array(1, 2, 3, 4, 6, 7));
if (!isset($_GET['addstock_mvt_reason']) || (Tools::isSubmit('submitAddstock_mvt_reason') && Tools::getValue('id_stock_mvt_reason')))
{
$first_list = '<hr /><h2>'.$this->l('Stock movement reason').'</h2>';
$first_list .= parent::initList();
}
$this->toolbar_title = $this->l('Stock : Stock movements reasons');
$first_list = parent::initList();
/*
* Manage second list
*/
$warehouses = Warehouse::getWarehouseList(true);
array_unshift($warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
$this->context->smarty->assign('list_warehouses', $warehouses);
$this->context->smarty->assign('current_warehouse', $this->getCurrentWarehouseId());
$this->tpl_list_vars['list_warehouses'] = $warehouses;
$this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId();
// reset actions, toolbar and query vars
$this->actions = array();
$this->toolbar_btn = array();
$this->toolbar_title = $this->l('Stock : Stock movements');
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
// override table, land, className and identifier for the current controller
$this->table = 'stock_mvt';
$this->className = 'StockMvt';
$this->identifier = 'id_stock_mvt';
$this->show_toolbar = false;
$this->lang = false;
// test if a filter is applied for this list
@@ -139,6 +139,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
{
if (Tools::isSubmit('addsupplier_order_state'))
{
$this->toolbar_title = $this->l('Stock : Add Supplier order state');
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Supplier Order State'),
@@ -263,6 +265,13 @@ class AdminSupplierOrdersControllerCore extends AdminController
Tools::isSubmit('submitAddsupplier_order') ||
Tools::isSubmit('submitUpdatesupplier_order'))
{
if (Tools::isSubmit('addsupplier_order') || Tools::isSubmit('submitAddsupplier_order'))
$this->toolbar_title = $this->l('Stock : Create new supplier order');
if (Tools::isSubmit('updatesupplier_order') || Tools::isSubmit('submitUpdatesupplier_order'))
$this->toolbar_title = $this->l('Stock : Manage supplier order');
$this->addJqueryUI('ui.datepicker');
//get warehouses list
@@ -405,8 +414,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
$this->addRowActionSkipList('edit', array(1, 2, 3, 4, 5, 6));
$this->addRowActionSkipList('delete', array(1, 2, 3, 4, 5, 6));
$first_list = '<hr /><h2>'.$this->l('Suppliers Orders States').'</h2>';
$first_list .= parent::initList();
$this->toolbar_title = $this->l('Stock : Suppliers Orders States');
$first_list = parent::initList();
/*
* Manage second list
@@ -415,6 +424,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
$this->actions = array();
$this->list_skip_actions = array();
$this->toolbar_btn = array();
$this->toolbar_title = '';
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
// override table, land, className and identifier for the current controller
@@ -786,8 +796,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
a.id_supplier_order_detail as id,
a.quantity_received as quantity_received,
a.quantity_expected as quantity_expected,
(a.quantity_expected - a.quantity_received) as quantity_left,
(a.quantity_expected - a.quantity_received) as quantity_received_today,
IF (a.quantity_expected < a.quantity_received, 0, a.quantity_expected - a.quantity_received) as quantity_left,
IF (a.quantity_expected < a.quantity_received, 0, a.quantity_expected - a.quantity_received) as quantity_received_today,
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as p_name,
p.reference as p_reference,
p.ean13 as p_ean13';
@@ -1098,9 +1108,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
if (Validate::isLoadedObject($supplier_order_detail))
{
// checks if quantity is valid
if (!Validate::isInt($quantity) ||
$quantity < 0 ||
$supplier_order_detail->quantity_received + $quantity > $supplier_order_detail->quantity_expected)
// It's possible to receive more quantity than expected in case of a shipping error from the supplier
if (!Validate::isInt($quantity) || $quantity < 0)
$this->_errors[] = sprintf(Tools::displayError('Quantity (%d) for product #%d is not valid'), (int)$quantity, (int)$id_supplier_order_detail);
else // everything is valid : updates
{
@@ -1117,7 +1126,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
}
}
if (!count($this_errors))
if (!count($this->_errors))
{
// display confirm message
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
@@ -51,6 +51,8 @@ class AdminWarehousesControllerCore extends AdminController
'employee' => array(
'title' => $this->l('Manager'),
'width' => 200,
'filter_key' => 'employee',
'havingFilter' => true
),
'location' => array(
'title' => $this->l('Location'),
@@ -115,9 +117,11 @@ class AdminWarehousesControllerCore extends AdminController
$query->where('active = 1');
$employees_array = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
$this->toolbar_title = $this->l('Stock : Warehouse management');
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Warehouse'),
'title' => $this->l('Warehouse management'),
'image' => '../img/admin/tab.gif'
),
'input' => array(