From fbbfb98db2fda0d1df1bb38cd5350937ae2872d9 Mon Sep 17 00:00:00 2001 From: mBertholino Date: Mon, 2 Jan 2012 09:31:07 +0000 Subject: [PATCH] [-] BO : #PSTEST-241 : We can delete group shops only if the group doesn't have any shops --- classes/shop/GroupShop.php | 2 +- controllers/admin/AdminGroupShopController.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/classes/shop/GroupShop.php b/classes/shop/GroupShop.php index 237034d78..15d172253 100644 --- a/classes/shop/GroupShop.php +++ b/classes/shop/GroupShop.php @@ -90,7 +90,7 @@ class GroupShopCore extends ObjectModel if (!$res = parent::delete()) return false; - foreach (Shop::getAssoTables() as $table_name => $row) + foreach (GroupShop::getAssoTables() as $table_name => $row) { $id = 'id_'.$row['type']; if ($row['type'] == 'fk_group_shop') diff --git a/controllers/admin/AdminGroupShopController.php b/controllers/admin/AdminGroupShopController.php index 1a200a256..f2a62ecaa 100644 --- a/controllers/admin/AdminGroupShopController.php +++ b/controllers/admin/AdminGroupShopController.php @@ -36,6 +36,9 @@ class AdminGroupShopControllerCore extends AdminController $this->addRowAction('edit'); + $this->addRowAction('delete'); + $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'),'confirm' => $this->l('Delete selected items?'))); + $this->context = Context::getContext(); if (!Tools::getValue('realedit')) @@ -235,6 +238,21 @@ class AdminGroupShopControllerCore extends AdminController return parent::renderForm(); } + public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) + { + parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); + $group_shop_delete_list = array(); + + // test store authorized to remove + foreach ($this->_list as $group_shop) + { + $shops = Shop::getShops(true, $group_shop['id_group_shop']); + if (!empty($shops)) + $group_shop_delete_list[] = $group_shop['id_group_shop']; + } + $this->addRowActionSkipList('delete', $group_shop_delete_list); + } + public function postProcess() { if (Tools::isSubmit('delete'.$this->table) || Tools::isSubmit('status') || Tools::isSubmit('status'.$this->table))