From 463d718dbb5edafdd299a11e7cef67e95c369bb8 Mon Sep 17 00:00:00 2001 From: fBrignoli Date: Thu, 16 Feb 2012 15:06:34 +0000 Subject: [PATCH] [-] BO : Bug Fixed #PSTEST-543 - Unable to bulk delete a tax rule git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13399 b9a71923-0436-4b27-9f14-aed3839534dd --- .../tax_rules/helpers/list/list_header.tpl | 89 +++++++++++++++++++ .../admin/AdminTaxRulesGroupController.php | 40 ++++++--- 2 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 admin-dev/themes/default/template/controllers/tax_rules/helpers/list/list_header.tpl diff --git a/admin-dev/themes/default/template/controllers/tax_rules/helpers/list/list_header.tpl b/admin-dev/themes/default/template/controllers/tax_rules/helpers/list/list_header.tpl new file mode 100644 index 000000000..f598aa497 --- /dev/null +++ b/admin-dev/themes/default/template/controllers/tax_rules/helpers/list/list_header.tpl @@ -0,0 +1,89 @@ +{* +* 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 +* @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 +*} + +{hook h='displayAdminListBefore'} +{if isset($name_controller)} + {capture name=hookName assign=hookName}display{$name_controller|ucfirst}ListBefore{/capture} + {hook h=$hookName} +{elseif isset($smarty.get.controller)} + {capture name=hookName assign=hookName}display{$smarty.get.controller|ucfirst|htmlentities}ListBefore{/capture} + {hook h=$hookName} +{/if} + + + +
+ + + +
+ + + {foreach $fields_display AS $key => $params} + + {/foreach} + {if $shop_link_type} + + {/if} + {if $has_actions} + + {/if} + + + + {foreach $fields_display AS $key => $params} + + {/foreach} + {if $shop_link_type} + + {/if} + {if $has_actions} + + {/if} + + diff --git a/controllers/admin/AdminTaxRulesGroupController.php b/controllers/admin/AdminTaxRulesGroupController.php index ae7a44a7c..58e11ba44 100644 --- a/controllers/admin/AdminTaxRulesGroupController.php +++ b/controllers/admin/AdminTaxRulesGroupController.php @@ -59,7 +59,7 @@ class AdminTaxRulesGroupControllerCore extends AdminController ) ); - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->bulk_actions = array('delete_tax_rule' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); parent::__construct(); } @@ -76,8 +76,9 @@ class AdminTaxRulesGroupControllerCore extends AdminController { $this->table = 'tax_rule'; $this->identifier = 'id_tax_rule'; + $this->className = 'TaxRule'; $this->lang = false; - $this->list_simple_header = true; + $this->list_simple_header = false; $this->toolbar_btn = null; $this->list_no_link = true; @@ -348,6 +349,8 @@ class AdminTaxRulesGroupControllerCore extends AdminController { if (Tools::isSubmit('deletetax_rule')) $this->processDeleteTaxRule(); + else if (Tools::isSubmit('submitBulkdelete_tax_rule')) + $this->processBulkDeleteTaxRules(); else if (Tools::getValue('action') == 'create_rule') $this->processCreateRule(); else @@ -397,17 +400,30 @@ class AdminTaxRulesGroupControllerCore extends AdminController Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$tr->id_tax_rules_group.'&conf=4&update'.$this->table.'&token='.$this->token); } - protected function processDeleteTaxRule() - { - $id_rule = (int)Tools::getValue('id_tax_rule'); - $tax_rule = new TaxRule($id_rule); + protected function processBulkDeleteTaxRules() + { + $this->deleteTaxRule(Tools::getValue('tax_ruleBox')); + } + + protected function processDeleteTaxRule() + { + $this->deleteTaxRule(array(Tools::getValue('id_tax_rule'))); + } + + protected function deleteTaxRule(array $id_tax_rule_list) + { + $result = true; + + foreach ($id_tax_rule_list as $id_tax_rule) + { + $tax_rule = new TaxRule((int)$id_tax_rule); + if (Validate::isLoadedObject($tax_rule)) + $result &= $tax_rule->delete(); + } + + Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.(int)$tax_rule->id_tax_rules_group.'&conf=4&update'.$this->table.'&token='.$this->token); + } - if (Validate::isLoadedObject($tax_rule)) - { - $tax_rule->delete(); - Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$tax_rule->id_tax_rules_group.'&conf=4&update'.$this->table.'&token='.$this->token); - } - } /** * check if the tax rule could be added in the database
+ {if $has_bulk_actions} + + {/if} + + {if isset($params.hint)}{$params.hint} {/if} + + {$params.title} + +
  +
+ {if $shop_link_type == 'shop'} + {l s='Shop'} + {else} + {l s='Group shop'} + {/if} +
  +
{l s='Actions'}