From 2fbafe711d74688a976ccce5d6972ac684c75fd9 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Tue, 22 Nov 2011 16:49:52 +0000 Subject: [PATCH] // Added toolbar to AdminModulesPositions and added full products list on AdminProducts --- .../modules_positions/list_modules.tpl | 15 +++++- .../themes/template/products/list_header.tpl | 13 ++++- .../admin/AdminModulesPositionsController.php | 22 ++++++-- controllers/admin/AdminProductsController.php | 53 +++++++++++-------- 4 files changed, 75 insertions(+), 28 deletions(-) diff --git a/admin-dev/themes/template/modules_positions/list_modules.tpl b/admin-dev/themes/template/modules_positions/list_modules.tpl index 25aee5993..66a5d5d82 100644 --- a/admin-dev/themes/template/modules_positions/list_modules.tpl +++ b/admin-dev/themes/template/modules_positions/list_modules.tpl @@ -29,7 +29,20 @@ var come_from = 'AdminModulesPositions'; - {l s='Transplant a module'}

+ +{if $show_toolbar} +
+
+ {include file="toolbar.tpl" toolbar_btn=$toolbar_btn} +
+

{block name=pageTitle} + {$title|default:' '} + {/block} +

+
+
+
+{/if}
{l s='Show'} : diff --git a/admin-dev/themes/template/products/list_header.tpl b/admin-dev/themes/template/products/list_header.tpl index b359ac2b5..e7bc5a727 100644 --- a/admin-dev/themes/template/products/list_header.tpl +++ b/admin-dev/themes/template/products/list_header.tpl @@ -1,10 +1,21 @@ {extends file="helper/list/list_header.tpl"} {block name=leadin} + {l s='Go to category:'} diff --git a/controllers/admin/AdminModulesPositionsController.php b/controllers/admin/AdminModulesPositionsController.php index f975cdb18..ff6c89ebd 100644 --- a/controllers/admin/AdminModulesPositionsController.php +++ b/controllers/admin/AdminModulesPositionsController.php @@ -18,7 +18,7 @@ * 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 +* @author PrestaShop SA o * @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7466 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) @@ -224,11 +224,16 @@ class AdminModulesPositionsControllerCore extends AdminController else $this->content .= $this->initMain(); - $this->context->smarty->assign(array('content' => $this->content)); + $this->context->smarty->assign(array( + 'content' => $this->content + )); } public function initMain() { + // Init toolbar + $this->initToolbarTitle(); + $admin_dir = basename(_PS_ADMIN_DIR_); $modules = Module::getModulesInstalled(); @@ -256,8 +261,16 @@ class AdminModulesPositionsControllerCore extends AdminController $this->addJqueryPlugin("tablednd"); + $this->toolbar_btn['save'] = array( + 'href' => self::$currentIndex.'&addToHook'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token, + 'desc' => $this->l('Transplant a module') + ); + $this->context->smarty->assign(array( - 'url_transplant' => self::$currentIndex.'&addToHook'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token, + 'show_toolbar' => true, + 'toolbar_btn' => $this->toolbar_btn, + 'title' => $this->toolbar_title, + 'toolbar_fix' => 'false', 'token' => $this->token, 'url_show_modules' => self::$currentIndex.'&token='.$this->token.'&show_modules=', 'modules' => $module_instances, @@ -276,6 +289,8 @@ class AdminModulesPositionsControllerCore extends AdminController public function initForm() { + // Init toolbar + $this->initToolbarTitle(); // toolbar (save, cancel, new, ..) $this->initToolbar(); $id_module = (int)(Tools::getValue('id_module')); @@ -343,6 +358,7 @@ class AdminModulesPositionsControllerCore extends AdminController 'modules' => $modules, 'show_toolbar' => true, 'toolbar_btn' => $this->toolbar_btn, + 'title' => $this->toolbar_title, 'table' => 'hook_module', )); diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index d86f7b727..e4ddddb3b 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -82,7 +82,7 @@ class AdminProductsControllerCore extends AdminController if ($id_category = Tools::getvalue('id_category')) $this->_category = new Category($id_category); else - $this->_category = new Category(1); + $this->_category = new Category(); $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (a.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang`) @@ -91,7 +91,11 @@ class AdminProductsControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$this->context->country->id.' AND tr.`id_state` = 0) LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)'; - $this->_filter = 'AND cp.`id_category` = '.(int)$this->_category->id; + + // if no category selected, display all products + if (Validate::isLoadedObject($this->_category)) + $this->_filter = 'AND cp.`id_category` = '.(int)$this->_category->id; + $this->_select = 'cl.name `name_category`, cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final'; parent::__construct(); @@ -1606,7 +1610,7 @@ class AdminProductsControllerCore extends AdminController { $this->display = 'list'; if ($id_category = (int)Tools::getValue('id_category')) - AdminController::$currentIndex .= '&id_category='.$id_category; + self::$currentIndex .= '&id_category='.$id_category; $this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : null, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : null, 0, null, $this->context->shop->getID(true)); $id_category = Tools::getValue('id_category', 1); @@ -1617,6 +1621,19 @@ class AdminProductsControllerCore extends AdminController $root_categ = Category::getRootCategory(); $children = $root_categ->getAllChildren(); $category_tree = array(); + + // Add category "all products" to tree + $all_categ = new Category(); + $all_categ->name = 'All products'; + $all_categ->selected = $this->_category->id_category == $all_categ->id; + $all_categ->dashes = ''; + $category_tree[] = $all_categ; + + // Add root category to tree + $root_categ->selected = $this->_category->id_category == $root_categ->id; + $root_categ->dashes = str_repeat(' - ',$root_categ->level_depth); + $category_tree[] = $root_categ; + foreach ($children as $k => $categ) { $categ = new Category($categ['id_category'],$this->context->language->id); @@ -1625,12 +1642,22 @@ class AdminProductsControllerCore extends AdminController $category_tree[] = $categ; } $this->tpl_list_vars['category_tree'] = $category_tree; + + // used to build the new url when changing category + $this->tpl_list_vars['base_url'] = preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token; } // @todo module free $this->tpl_form_vars['vat_number'] = file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'); parent::initContent(); } + public function initList() + { + if (!Tools::getValue('id_category')) + unset($this->fieldsDisplay['position']); + return parent::initList(); + } + public function ajaxProcessProductManufacturers() { $manufacturers = Manufacturer::getManufacturers(); @@ -1643,26 +1670,6 @@ class AdminProductsControllerCore extends AdminController } } - /** - * displayList show ordered list of current category - * - * @param mixed $token - * @return void - */ - public function displayList($token = null) - { - /* Display list header (filtering, pagination and column names) */ - // $this->displayListHeader($token); - if (!sizeof($this->_list)) - echo ''.$this->l('No items found').''; - - /* Show the content of the table */ - $this->displayListContent($token); - - /* Close list table and submit button */ - $this->displayListFooter($token); - } - /** * Build a categories tree *