From f65dd294db97abbc0a95d4f9bae56d4515291097 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Mon, 4 Jun 2012 12:00:09 +0000 Subject: [PATCH] //added bulk action for enable or disable item --- classes/controller/AdminController.php | 40 ++++++++++++ controllers/admin/AdminCarriersController.php | 6 +- .../admin/AdminCountriesController.php | 16 ++--- .../admin/AdminCurrenciesController.php | 6 +- .../admin/AdminLanguagesController.php | 6 +- controllers/admin/AdminStatesController.php | 16 ++--- controllers/admin/AdminStoresController.php | 7 ++- .../admin/AdminTaxRulesGroupController.php | 6 +- controllers/admin/AdminTaxesController.php | 62 +++++++++++++++---- .../admin/AdminWebserviceController.php | 8 ++- controllers/admin/AdminZonesController.php | 11 ++-- 11 files changed, 147 insertions(+), 37 deletions(-) diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index b3ce8362d..de36fd542 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -2527,6 +2527,46 @@ class AdminControllerCore extends Controller else return false; } + + /** + * Enable multiple items + * + * @return boolean true if succcess + */ + protected function processBulkEnableSelection() + { + return $this->processBulkStatusSelection(1); + } + + /** + * Disable multiple items + * + * @return boolean true if succcess + */ + protected function processBulkDisableSelection() + { + return $this->processBulkStatusSelection(0); + } + + /** + * Toggle status of multiple items + * + * @return boolean true if succcess + */ + protected function processBulkStatusSelection($status) + { + $result = true; + if (is_array($this->boxes) && !empty($this->boxes)) + { + foreach ($this->boxes as $id) + { + $object = new $this->className((int)$id); + $object->active = (int)$status; + $result &= $object->update(); + } + } + return $result; + } protected function processBulkAffectZone() { diff --git a/controllers/admin/AdminCarriersController.php b/controllers/admin/AdminCarriersController.php index 318c31034..684f0750d 100644 --- a/controllers/admin/AdminCarriersController.php +++ b/controllers/admin/AdminCarriersController.php @@ -44,7 +44,11 @@ class AdminCarriersControllerCore extends AdminController $this->context = Context::getContext(); - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->bulk_actions = array( + 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')) + ); $this->fieldImageSettings = array( 'name' => 'logo', diff --git a/controllers/admin/AdminCountriesController.php b/controllers/admin/AdminCountriesController.php index 47b105102..0cbba7dc4 100644 --- a/controllers/admin/AdminCountriesController.php +++ b/controllers/admin/AdminCountriesController.php @@ -39,14 +39,14 @@ class AdminCountriesControllerCore extends AdminController $this->requiredDatabase = true; $this->context = Context::getContext(); - - $this->bulk_actions = array('delete' => array( - 'text' => $this->l('Delete selected'), - 'confirm' => $this->l('Delete selected items?')), - 'affectzone' => array( - 'text' => $this->l('Assign to a new zone')) - ); - + + $this->bulk_actions = array( + 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')), + 'affectzone' => array('text' => $this->l('Assign to a new zone')) + ); + $this->fieldImageSettings = array( 'name' => 'logo', 'dir' => 'st' diff --git a/controllers/admin/AdminCurrenciesController.php b/controllers/admin/AdminCurrenciesController.php index 5ffdc0a5b..aeb2475eb 100644 --- a/controllers/admin/AdminCurrenciesController.php +++ b/controllers/admin/AdminCurrenciesController.php @@ -51,7 +51,11 @@ class AdminCurrenciesControllerCore extends AdminController 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), ); - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->bulk_actions = array( + 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')) + ); $this->fields_options = array( 'change' => array( diff --git a/controllers/admin/AdminLanguagesController.php b/controllers/admin/AdminLanguagesController.php index f8f2ef1de..2b11083c8 100644 --- a/controllers/admin/AdminLanguagesController.php +++ b/controllers/admin/AdminLanguagesController.php @@ -91,7 +91,11 @@ class AdminLanguagesControllerCore extends AdminController ) ); - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->bulk_actions = array( + 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')) + ); $this->specificConfirmDelete = $this->l('When you delete a language, all related translations in the database will be deleted. Are you sure you want to delete this language?'); parent::__construct(); diff --git a/controllers/admin/AdminStatesController.php b/controllers/admin/AdminStatesController.php index 834484865..53436b627 100644 --- a/controllers/admin/AdminStatesController.php +++ b/controllers/admin/AdminStatesController.php @@ -41,14 +41,14 @@ class AdminStatesControllerCore extends AdminController if (!Tools::getValue('realedit')) $this->deleted = false; - - $this->bulk_actions = array('delete' => array( - 'text' => $this->l('Delete selected'), - 'confirm' => $this->l('Delete selected items?')), - 'affectzone' => array( - 'text' => $this->l('Affect a new zone')) - ); - + + $this->bulk_actions = array( + 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')), + 'affectzone' => array('text' => $this->l('Affect a new zone')) + ); + $this->fields_list = array( 'id_state' => array( 'title' => $this->l('ID'), diff --git a/controllers/admin/AdminStoresController.php b/controllers/admin/AdminStoresController.php index e123e0d85..71c2a7049 100644 --- a/controllers/admin/AdminStoresController.php +++ b/controllers/admin/AdminStoresController.php @@ -58,7 +58,11 @@ class AdminStoresControllerCore extends AdminController 'active' => array('title' => $this->l('Enabled'), 'width' => 70, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false) ); - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->bulk_actions = array( + 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')) + ); $this->fields_options = array( 'general' => array( @@ -496,6 +500,7 @@ class AdminStoresControllerCore extends AdminController 'type' => 'text' ), ); + return $formFields; } diff --git a/controllers/admin/AdminTaxRulesGroupController.php b/controllers/admin/AdminTaxRulesGroupController.php index fc2ed8ddb..ff0a335cc 100644 --- a/controllers/admin/AdminTaxRulesGroupController.php +++ b/controllers/admin/AdminTaxRulesGroupController.php @@ -59,7 +59,11 @@ 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' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')) + ); parent::__construct(); } diff --git a/controllers/admin/AdminTaxesController.php b/controllers/admin/AdminTaxesController.php index 0d2e798e6..f4b836c74 100644 --- a/controllers/admin/AdminTaxesController.php +++ b/controllers/admin/AdminTaxesController.php @@ -34,13 +34,19 @@ class AdminTaxesControllerCore extends AdminController $this->lang = true; $this->addRowAction('edit'); $this->addRowAction('delete'); - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + + $this->bulk_actions = array( + 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')) + ); $this->fields_list = array( - 'id_tax' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'name' => array('title' => $this->l('Name'), 'width' => 'auto'), - 'rate' => array('title' => $this->l('Rate'), 'align' => 'center', 'suffix' => '%', 'width' => 50), - 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)); + 'id_tax' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), + 'name' => array('title' => $this->l('Name'), 'width' => 'auto'), + 'rate' => array('title' => $this->l('Rate'), 'align' => 'center', 'suffix' => '%', 'width' => 50), + 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false) + ); $ecotax_desc = ''; if (Configuration::get('PS_USE_ECOTAX')) @@ -50,18 +56,52 @@ class AdminTaxesControllerCore extends AdminController 'general' => array( 'title' => $this->l('Tax options'), 'fields' => array( - 'PS_TAX' => array('title' => $this->l('Enable tax:'), 'desc' => $this->l('Select whether or not to include tax on purchases'), 'cast' => 'intval', 'type' => 'bool'), - 'PS_TAX_DISPLAY' => array('title' => $this->l('Display tax in cart:'), 'desc' => $this->l('Select whether or not to display tax on a distinct line in the cart'), 'cast' => 'intval', 'type' => 'bool'), - 'PS_TAX_ADDRESS_TYPE' => array('title' => $this->l('Base on:'), 'cast' => 'pSQL', 'type' => 'select', 'list' => array(array('name' => $this->l('Invoice Address'), 'id' => 'id_address_invoice'), array('name' => $this->l('Delivery Address'), 'id' => 'id_address_delivery')), 'identifier' => 'id'), - 'PS_USE_ECOTAX' => array('title' => $this->l('Use ecotax'), 'desc' => $ecotax_desc, 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), + 'PS_TAX' => array( + 'title' => $this->l('Enable tax:'), + 'desc' => $this->l('Select whether or not to include tax on purchases'), + 'cast' => 'intval', 'type' => 'bool'), + 'PS_TAX_DISPLAY' => array( + 'title' => $this->l('Display tax in cart:'), + 'desc' => $this->l('Select whether or not to display tax on a distinct line in the cart'), + 'cast' => 'intval', + 'type' => 'bool'), + 'PS_TAX_ADDRESS_TYPE' => array( + 'title' => $this->l('Base on:'), + 'cast' => 'pSQL', + 'type' => 'select', + 'list' => array( + array( + 'name' => $this->l('Invoice Address'), + 'id' => 'id_address_invoice' + ), + array( + 'name' => $this->l('Delivery Address'), + 'id' => 'id_address_delivery') + ), + 'identifier' => 'id' + ), + 'PS_USE_ECOTAX' => array( + 'title' => $this->l('Use ecotax'), + 'desc' => $ecotax_desc, + 'validation' => 'isBool', + 'cast' => 'intval', + 'type' => 'bool' + ), ), 'submit' => array() ), ); if (Configuration::get('PS_USE_ECOTAX')) - $this->fields_options['general']['fields']['PS_ECOTAX_TAX_RULES_GROUP_ID'] = array('title' => $this->l('Ecotax:'), 'desc' => $this->l('The tax to apply on the ecotax (e.g. French ecotax: 19.6%).'), - 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_tax', 'identifier' => 'id_tax_rules_group', 'list' => TaxRulesGroup::getTaxRulesGroupsForOptions()); + $this->fields_options['general']['fields']['PS_ECOTAX_TAX_RULES_GROUP_ID'] = array( + 'title' => $this->l('Ecotax:'), + 'desc' => $this->l('The tax to apply on the ecotax (e.g. French ecotax: 19.6%).'), + 'cast' => 'intval', + 'type' => 'select', + 'identifier' => 'id_tax', + 'identifier' => 'id_tax_rules_group', + 'list' => TaxRulesGroup::getTaxRulesGroupsForOptions() + ); parent::__construct(); } diff --git a/controllers/admin/AdminWebserviceController.php b/controllers/admin/AdminWebserviceController.php index df4b99084..f37e33c44 100755 --- a/controllers/admin/AdminWebserviceController.php +++ b/controllers/admin/AdminWebserviceController.php @@ -39,7 +39,13 @@ class AdminWebserviceControllerCore extends AdminController $this->edit = true; $this->delete = true; $this->id_lang_default = Configuration::get('PS_LANG_DEFAULT'); - + + $this->bulk_actions = array( + 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')) + ); + $this->fields_list = array( 'key' => array( 'title' => $this->l('Key'), diff --git a/controllers/admin/AdminZonesController.php b/controllers/admin/AdminZonesController.php index a105f4ad3..d2045301c 100644 --- a/controllers/admin/AdminZonesController.php +++ b/controllers/admin/AdminZonesController.php @@ -34,7 +34,7 @@ class AdminZonesControllerCore extends AdminController $this->table = 'zone'; $this->className = 'Zone'; $this->lang = false; - + $this->fields_list = array( 'id_zone' => array( 'title' => $this->l('ID'), @@ -54,9 +54,12 @@ class AdminZonesControllerCore extends AdminController 'orderby' => false ) ); - - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); - + $this->bulk_actions = array( + 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), + 'enableSelection' => array('text' => $this->l('Enable selection')), + 'disableSelection' => array('text' => $this->l('Disable selection')) + ); + parent::__construct(); }