// #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 committed 2011-11-07 15:18:47 +00:00
1 parent 55166aefa1
commit be6473f82d
10 files changed
+66 -157

No files matched your search

@@ -59,6 +59,8 @@
{/if}{* End if simple_header *} {/if}{* End if simple_header *}
<a name="{$table}">&nbsp;</a>
{if $show_toolbar} {if $show_toolbar}
<div class="toolbar-placeholder"> <div class="toolbar-placeholder">
<div class="toolbarBox {if $toolbar_fix}toolbarHead{/if}"> <div class="toolbarBox {if $toolbar_fix}toolbarHead{/if}">
@@ -74,7 +76,7 @@
{/if} {/if}
<div class="leadin">{block name="leadin"}{/block}</div> <div class="leadin">{block name="leadin"}{/block}</div>
<a name="{$table}">&nbsp;</a>
<form method="post" action="{$action}" class="form"> <form method="post" action="{$action}" class="form">
<input type="hidden" id="submitFilter{$table}" name="submitFilter{$table}" value="0"/> <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) if ($this->getCurrentCoverageWarehouse() != -1)
$this->_where .= ' AND s.id_warehouse = '.$this->getCurrentCoverageWarehouse(); $this->_where .= ' AND s.id_warehouse = '.$this->getCurrentCoverageWarehouse();
$this->context->smarty->assign('stock_cover_periods', $this->stock_cover_periods); $this->tpl_list_vars['stock_cover_periods'] = $this->stock_cover_periods;
$this->context->smarty->assign('stock_cover_cur_period', $this->getCurrentCoveragePeriod()); $this->tpl_list_vars['stock_cover_cur_period'] = $this->getCurrentCoveragePeriod();
$this->context->smarty->assign('stock_cover_warehouses', $this->stock_cover_warehouses); $this->tpl_list_vars['stock_cover_warehouses'] = $this->stock_cover_warehouses;
$this->context->smarty->assign('stock_cover_cur_warehouse', $this->getCurrentCoverageWarehouse()); $this->tpl_list_vars['stock_cover_cur_warehouse'] = $this->getCurrentCoverageWarehouse();
$this->displayInformation( $this->displayInformation(
$this->l('Considering the coverage period choosen and the quantity of products/combinations that you sold, $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 //no link on list rows
$this->list_no_link = true; $this->list_no_link = true;
$this->context->smarty->assign('list_warehouses', Warehouse::getWarehouseList(true)); $this->tpl_list_vars['list_warehouses'] = Warehouse::getWarehouseList(true);
$this->context->smarty->assign('current_warehouse', $this->getCurrentWarehouseId()); $this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId();
return parent::initList(); return parent::initList();
} }
@@ -86,6 +86,8 @@ class AdminStockManagementControllerCore extends AdminController
// no link on list rows // no link on list rows
$this->list_no_link = true; $this->list_no_link = true;
$this->toolbar_btn = array();
$this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations'; $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)'; $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' => '#', 'href' => '#',
'desc' => $this->l('Save') '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; break;
default: default:
@@ -705,13 +720,22 @@ class AdminStockManagementControllerCore extends AdminController
parent::init(); parent::init();
if (Tools::isSubmit('addstock')) if (Tools::isSubmit('addstock'))
{
$this->display = 'addstock'; $this->display = 'addstock';
$this->toolbar_title = $this->l('Stock : Add product');
}
if (Tools::isSubmit('removestock')) if (Tools::isSubmit('removestock'))
{
$this->display = 'removestock'; $this->display = 'removestock';
$this->toolbar_title = $this->l('Stock : Remove product');
}
if (Tools::isSubmit('transferstock')) if (Tools::isSubmit('transferstock'))
{
$this->display = 'transferstock'; $this->display = 'transferstock';
$this->toolbar_title = $this->l('Stock : Transfer product');
}
} }
/** /**
@@ -760,6 +784,8 @@ class AdminStockManagementControllerCore extends AdminController
// Render list // Render list
$helper = new HelperList(); $helper = new HelperList();
$helper->bulk_actions = array(); $helper->bulk_actions = array();
$helper->toolbar_fix = $this->toolbar_fix;
$helper->show_toolbar = false;
$helper->actions = $this->actions; $helper->actions = $this->actions;
$helper->list_skip_actions = $this->list_skip_actions; $helper->list_skip_actions = $this->list_skip_actions;
$helper->no_link = true; $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')) if (file_exists($this->context->smarty->template_dir.'/'.$this->tpl_folder.'form.tpl'))
$helper->tpl = $this->tpl_folder.'form.tpl'; $helper->tpl = $this->tpl_folder.'form.tpl';
$this->setHelperDisplay($helper);
$helper->submit_action = $this->display; $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->id = null; // no display standard hidden field in the form
$helper->languages = $this->_languages; $helper->languages = $this->_languages;
$helper->default_form_language = $this->default_form_language; $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(); parent::__construct();
} }
@@ -106,6 +106,8 @@ class AdminStockMvtControllerCore extends AdminController
*/ */
public function initForm() public function initForm()
{ {
$this->toolbar_title = $this->l('Stock : Add Stock movement reason');
$this->fields_form = array( $this->fields_form = array(
'legend' => array( 'legend' => array(
'title' => $this->l('Stock Movement Reason'), 'title' => $this->l('Stock Movement Reason'),
@@ -176,30 +178,27 @@ class AdminStockMvtControllerCore extends AdminController
$this->addRowActionSkipList('edit', array(6, 7)); $this->addRowActionSkipList('edit', array(6, 7));
$this->addRowActionSkipList('delete', array(1, 2, 3, 4, 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'))) $this->toolbar_title = $this->l('Stock : Stock movements reasons');
{ $first_list = parent::initList();
$first_list = '<hr /><h2>'.$this->l('Stock movement reason').'</h2>';
$first_list .= parent::initList();
}
/* /*
* Manage second list * Manage second list
*/ */
$warehouses = Warehouse::getWarehouseList(true); $warehouses = Warehouse::getWarehouseList(true);
array_unshift($warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses'))); array_unshift($warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
$this->context->smarty->assign('list_warehouses', $warehouses); $this->tpl_list_vars['list_warehouses'] = $warehouses;
$this->context->smarty->assign('current_warehouse', $this->getCurrentWarehouseId()); $this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId();
// reset actions, toolbar and query vars // reset actions, toolbar and query vars
$this->actions = array(); $this->actions = array();
$this->toolbar_btn = array(); $this->toolbar_btn = array();
$this->toolbar_title = $this->l('Stock : Stock movements');
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter); unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
// override table, land, className and identifier for the current controller // override table, land, className and identifier for the current controller
$this->table = 'stock_mvt'; $this->table = 'stock_mvt';
$this->className = 'StockMvt'; $this->className = 'StockMvt';
$this->identifier = 'id_stock_mvt'; $this->identifier = 'id_stock_mvt';
$this->show_toolbar = false;
$this->lang = false; $this->lang = false;
// test if a filter is applied for this list // test if a filter is applied for this list
@@ -139,6 +139,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
{ {
if (Tools::isSubmit('addsupplier_order_state')) if (Tools::isSubmit('addsupplier_order_state'))
{ {
$this->toolbar_title = $this->l('Stock : Add Supplier order state');
$this->fields_form = array( $this->fields_form = array(
'legend' => array( 'legend' => array(
'title' => $this->l('Supplier Order State'), 'title' => $this->l('Supplier Order State'),
@@ -263,6 +265,13 @@ class AdminSupplierOrdersControllerCore extends AdminController
Tools::isSubmit('submitAddsupplier_order') || Tools::isSubmit('submitAddsupplier_order') ||
Tools::isSubmit('submitUpdatesupplier_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'); $this->addJqueryUI('ui.datepicker');
//get warehouses list //get warehouses list
@@ -405,8 +414,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
$this->addRowActionSkipList('edit', array(1, 2, 3, 4, 5, 6)); $this->addRowActionSkipList('edit', array(1, 2, 3, 4, 5, 6));
$this->addRowActionSkipList('delete', 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>'; $this->toolbar_title = $this->l('Stock : Suppliers Orders States');
$first_list .= parent::initList(); $first_list = parent::initList();
/* /*
* Manage second list * Manage second list
@@ -415,6 +424,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
$this->actions = array(); $this->actions = array();
$this->list_skip_actions = array(); $this->list_skip_actions = array();
$this->toolbar_btn = array(); $this->toolbar_btn = array();
$this->toolbar_title = '';
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter); unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
// override table, land, className and identifier for the current controller // 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.id_supplier_order_detail as id,
a.quantity_received as quantity_received, a.quantity_received as quantity_received,
a.quantity_expected as quantity_expected, a.quantity_expected as quantity_expected,
(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_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_received_today,
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as p_name, IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as p_name,
p.reference as p_reference, p.reference as p_reference,
p.ean13 as p_ean13'; p.ean13 as p_ean13';
@@ -1098,9 +1108,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
if (Validate::isLoadedObject($supplier_order_detail)) if (Validate::isLoadedObject($supplier_order_detail))
{ {
// checks if quantity is valid // checks if quantity is valid
if (!Validate::isInt($quantity) || // It's possible to receive more quantity than expected in case of a shipping error from the supplier
$quantity < 0 || if (!Validate::isInt($quantity) || $quantity < 0)
$supplier_order_detail->quantity_received + $quantity > $supplier_order_detail->quantity_expected)
$this->_errors[] = sprintf(Tools::displayError('Quantity (%d) for product #%d is not valid'), (int)$quantity, (int)$id_supplier_order_detail); $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 else // everything is valid : updates
{ {
@@ -1117,7 +1126,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
} }
} }
if (!count($this_errors)) if (!count($this->_errors))
{ {
// display confirm message // display confirm message
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token; $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
@@ -51,6 +51,8 @@ class AdminWarehousesControllerCore extends AdminController
'employee' => array( 'employee' => array(
'title' => $this->l('Manager'), 'title' => $this->l('Manager'),
'width' => 200, 'width' => 200,
'filter_key' => 'employee',
'havingFilter' => true
), ),
'location' => array( 'location' => array(
'title' => $this->l('Location'), 'title' => $this->l('Location'),
@@ -115,9 +117,11 @@ class AdminWarehousesControllerCore extends AdminController
$query->where('active = 1'); $query->where('active = 1');
$employees_array = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); $employees_array = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
$this->toolbar_title = $this->l('Stock : Warehouse management');
$this->fields_form = array( $this->fields_form = array(
'legend' => array( 'legend' => array(
'title' => $this->l('Warehouse'), 'title' => $this->l('Warehouse management'),
'image' => '../img/admin/tab.gif' 'image' => '../img/admin/tab.gif'
), ),
'input' => array( 'input' => array(