From 1f971275a0f252fb26a1556bbe4f91c62899c8be Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Tue, 20 Jun 2017 10:09:07 +0200 Subject: [PATCH] multiple disable/enable product --- adm/tabs/AdminProducts.php | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/adm/tabs/AdminProducts.php b/adm/tabs/AdminProducts.php index 4cb5869a..9b0e2932 100755 --- a/adm/tabs/AdminProducts.php +++ b/adm/tabs/AdminProducts.php @@ -710,6 +710,38 @@ class AdminProducts extends AdminTab $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); } + /* @Override Antadis disable multiple objects */ + elseif (Tools::getValue('submitDisable'.$this->table) || Tools::getValue('submitEnable'.$this->table)) + { + $active = Tools::getValue('submitDisable'.$this->table)?0:1; + if (isset($_POST[$this->table.'Box'])) { + $object = new $this->className(); + + if (isset($object->noZeroObject) AND + (sizeof(call_user_func(array($this->className, $object->noZeroObject))) <= 1 OR sizeof($_POST[$this->table.'Box']) == sizeof(call_user_func(array($this->className, $object->noZeroObject)))) + ){ + $this->_errors[] = Tools::displayError('You need at least one object.').' '.$this->table.'
'.Tools::displayError('You cannot disable/enable all of the items.'); + } else { + $result = true; + foreach(Tools::getValue($this->table.'Box') as $id) { + $toChange = new $this->className($id); + $toChange->active = (int)$active; + $result = $result AND $toChange->update(); + } + + if ($result) { + $id_category = Tools::getValue('id_category'); + $category_url = empty($id_category) ? '' : '&id_category='.$id_category; + + Tools::redirectAdmin($currentIndex.'&conf=2&token='.$token.$category_url); + } + $this->_errors[] = Tools::displayError('An error occurred while deleting selection.'); + } + } else { + $this->_errors[] = Tools::displayError('You must select at least one element to delete.'); + } + } + /* @Override - Antadis, delete some images in same time */ elseif (Tools::isSubmit('deleteImages') && Tools::getValue('ids_image')) { @@ -1910,8 +1942,12 @@ class AdminProducts extends AdminTab echo ''; global $cookie; + echo '

'; if ($this->delete) - echo '

'; + echo ''; + echo ' '; + echo ' '; + echo '

'; echo '
'; $languages = Language::getLanguages(FALSE);