diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index d7a52cd1910..f975eaabc67 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -890,39 +890,7 @@ class Entrepot extends CommonObject */ public function setCategories($categories) { - $type_categ = Categorie::TYPE_WAREHOUSE; - - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - - // Get current categories require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $c = new Categorie($this->db); - $existing = $c->containing($this->id, $type_categ, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } - - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, $type_categ); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, $type_categ); - } - } - - return; + return parent::setCategoriesCommon($categories, Categorie::TYPE_WAREHOUSE); } } diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index f2c7133618b..0ff7cf029c7 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -46,6 +46,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'stocklist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$toselect = GETPOST('toselect', 'array'); + $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha"); @@ -160,7 +162,7 @@ if (empty($reshook)) { $search[$key] = ''; } - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') @@ -174,6 +176,7 @@ if (empty($reshook)) $objectlabel = 'Warehouse'; $permissiontoread = $user->rights->stock->lire; $permissiontodelete = $user->rights->stock->supprimer; + $permissiontoadd = $user->rights->stock->creer; $uploaddir = $conf->stock->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -344,6 +347,7 @@ $arrayofmassactions = array( ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($user->rights->stock->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
';