Merge branch 'ticket-13532-ProductDisable' into develop

This commit is contained in:
Marion Muszynski 2017-06-20 10:09:22 +02:00
commit d3e9c70bd8

View File

@ -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.').' <b>'.$this->table.'</b><br />'.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 '</table>';
global $cookie;
echo '<p>';
if ($this->delete)
echo '<p><input type="submit" class="button" name="submitDel'.$this->table.'" value="'.$this->l('Delete selection').'" onclick="return confirm(\''.$this->l('Delete selected items?', __CLASS__, TRUE, FALSE).'\');" /></p>';
echo '<input type="submit" class="button" name="submitDel'.$this->table.'" value="'.$this->l('Delete selection').'" onclick="return confirm(\''.$this->l('Delete selected items?', __CLASS__, TRUE, FALSE).'\');" />';
echo ' <input type="submit" class="button" name="submitDisable'.$this->table.'" value="'.$this->l('Disable selection').'" onclick="return confirm(\''.$this->l('Disable selected items?', __CLASS__, TRUE, FALSE).'\');" />';
echo ' <input type="submit" class="button" name="submitEnable'.$this->table.'" value="'.$this->l('Enable selection').'" onclick="return confirm(\''.$this->l('Enable selected items?', __CLASS__, TRUE, FALSE).'\');" />';
echo '</p>';
echo '<hr>';
$languages = Language::getLanguages(FALSE);