diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 1a4c80db28d..4b4dcc518d2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2688,12 +2688,12 @@ class Adherent extends CommonObject // Process foreach ($to_del as $del) { if ($c->fetch($del) > 0) { - $c->del_type($this, 'member'); + $c->del_type($this, Categorie::TYPE_MEMBER); } } foreach ($to_add as $add) { if ($c->fetch($add) > 0) { - $c->add_type($this, 'member'); + $c->add_type($this, Categorie::TYPE_MEMBER); } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index edbabd4476d..4bf6a4d73e3 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -53,7 +53,7 @@ class Categorie extends CommonObject const TYPE_PROJECT = 'project'; const TYPE_ACCOUNT = 'bank_account'; const TYPE_BANK_LINE = 'bank_line'; - const TYPE_STOCK = 'stock'; + const TYPE_WAREHOUSE = 'warehouse'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -76,7 +76,7 @@ class Categorie extends CommonObject 'project' => 6, 'user' => 7, 'bank_line' => 8, - 'stock' => 9, + 'warehouse' => 9, ); /** @@ -92,13 +92,13 @@ class Categorie extends CommonObject 6 => 'project', 7 => 'user', 8 => 'bank_line', - 9 => 'stock', + 9 => 'warehouse', ); /** * @var array Foreign keys mapping from type string * - * @note Move to const array when PHP 5.6 will be our minimum target + * @TODO Move to const array when PHP 5.6 will be our minimum target */ protected $MAP_CAT_FK = array( 'product' => 'product', @@ -107,14 +107,14 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'socpeople', 'user' => 'user', - 'account' => 'account', // old for bank_account + 'account' => 'account', // old key for bank_account 'bank_account' => 'account', 'project' => 'project', - 'stock' => 'entrepot', + 'warehouse'=> 'warehouse', ); /** - * @var array Category tables mapping from type string + * @var array Category tables mapping from type string (llx_categorie_...) * * @note Move to const array when PHP 5.6 will be our minimum target */ @@ -125,10 +125,10 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'contact', 'user' => 'user', - 'account' => 'account', // old for bank_account + 'account' => 'account', // old key for bank_account 'bank_account'=> 'account', 'project' => 'project', - 'stock' => 'entrepot', + 'warehouse'=> 'warehouse', ); /** @@ -146,11 +146,11 @@ class Categorie extends CommonObject 'account' => 'Account', // old for bank account 'bank_account' => 'Account', 'project' => 'Project', - 'stock' => 'Entrepot', + 'warehouse'=> 'Entrepot', ); /** - * @var array Object table mapping from type string + * @var array Object table mapping from type string (table llx_...) * * @note Move to const array when PHP 5.6 will be our minimum target */ @@ -163,7 +163,7 @@ class Categorie extends CommonObject 'user' => 'user', 'account' => 'bank_account', 'project' => 'projet', - 'stock' => 'entrepot', + 'warehouse'=> 'entrepot', ); /** @@ -204,14 +204,16 @@ class Categorie extends CommonObject /** * @var string Category type * + * @see Categorie::TYPE_ACCOUNT * @see Categorie::TYPE_PRODUCT * @see Categorie::TYPE_SUPPLIER * @see Categorie::TYPE_CUSTOMER * @see Categorie::TYPE_MEMBER * @see Categorie::TYPE_CONTACT * @see Categorie::TYPE_USER - * @see Categorie::TYPE_ACCOUNT * @see Categorie::TYPE_PROJECT + * @see Categorie::TYPE_BANK_LINE + * @see Categorie::TYPE_WAREHOUSE */ public $type; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index ab6c6df5a26..52936f57a78 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -58,7 +58,7 @@ elseif ($type == Categorie::TYPE_CONTACT) { $title=$langs->trans("ContactsCate elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='bank_account'; } elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; } elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; } -elseif ($type == Categorie::TYPE_STOCK) { $title=$langs->trans("StocksCategoriesArea"); $typetext='stock'; } +elseif ($type == Categorie::TYPE_WAREHOUSE) { $title=$langs->trans("StocksCategoriesArea"); $typetext='warehouse'; } else { $title=$langs->trans("CategoriesArea"); $typetext='unknown'; } $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 282a296a5f1..02b8e01d3bf 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -989,12 +989,12 @@ class Account extends CommonObject // Process foreach($to_del as $del) { if ($c->fetch($del) > 0) { - $c->del_type($this, 'account'); + $c->del_type($this, Categorie::TYPE_ACCOUNT); } } foreach ($to_add as $add) { if ($c->fetch($add) > 0) { - $c->add_type($this, 'account'); + $c->add_type($this, Categorie::TYPE_ACCOUNT); } } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ebfafa698b7..f9ad9ca358d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1406,12 +1406,12 @@ class Contact extends CommonObject // Process foreach ($to_del as $del) { if ($c->fetch($del) > 0) { - $c->del_type($this, 'contact'); + $c->del_type($this, Categorie::TYPE_CONTACT); } } foreach ($to_add as $add) { if ($c->fetch($add) > 0) { - $c->add_type($this, 'contact'); + $c->add_type($this, Categorie::TYPE_CONTACT); } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c470231e5de..fe815bd33b0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6481,6 +6481,7 @@ class Form if ($rendermode == 0) { + $arrayselected=array(); $cate_arbo = $this->select_all_categories($type, '', 'parent', 64, 0, 1); foreach($categories as $c) { $arrayselected[] = $c->id; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 32bf5b8e08e..758f12b3f5e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1522,10 +1522,13 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/product/stock/massstockmove.php", $langs->trans("MassStockTransferShort"), 1, $user->rights->stock->mouvement->creer); if ($conf->supplier_order->enabled) $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire); + + // Categories for warehouses + if (! empty($conf->categorie->enabled)) + { + $newmenu->add("/categories/index.php?leftmenu=stock&type=9", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); + } } - //Categories Stock - $newmenu->add("/categories/index.php?leftmenu=stock&type=9", $langs->trans("StockCategoriesShort"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat'); - $newmenu->add("/categories/card.php?leftmenu=stock&action=create&type=9", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer); // Inventory if ($conf->global->MAIN_FEATURES_LEVEL >= 2) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 45bd666abb0..a55938030c4 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -36,6 +36,21 @@ UPDATE llx_expensereport set paid = 1 WHERE fk_statut = 6 and paid = 0; -- For v11 +create table llx_categorie_warehouse +( + fk_categorie integer NOT NULL, + fk_warehouse integer NOT NULL, + import_key varchar(14) +) ENGINE=innodb; + +ALTER TABLE llx_categorie_warehouse ADD PRIMARY KEY pk_categorie_warehouse (fk_categorie, fk_warehouse); +ALTER TABLE llx_categorie_warehouse ADD INDEX idx_categorie_warehouse_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_warehouse ADD INDEX idx_categorie_warehouse_fk_warehouse (fk_warehouse); + +ALTER TABLE llx_categorie_warehouse ADD CONSTRAINT fk_categorie_warehouse_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_warehouse ADD CONSTRAINT fk_categorie_warehouse_fk_warehouse_rowid FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot (rowid); + + create table llx_holiday_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, diff --git a/htdocs/install/mysql/tables/llx_categorie_stock.key.sql b/htdocs/install/mysql/tables/llx_categorie_warehouse.key.sql similarity index 61% rename from htdocs/install/mysql/tables/llx_categorie_stock.key.sql rename to htdocs/install/mysql/tables/llx_categorie_warehouse.key.sql index e57361ed8bb..0df8bb0e6f5 100644 --- a/htdocs/install/mysql/tables/llx_categorie_stock.key.sql +++ b/htdocs/install/mysql/tables/llx_categorie_warehouse.key.sql @@ -17,9 +17,9 @@ -- -- ============================================================================ -ALTER TABLE llx_categorie_entrepot ADD PRIMARY KEY pk_categorie_entrepot (fk_categorie, fk_entrepot); -ALTER TABLE llx_categorie_entrepot ADD INDEX idx_categorie_entrepot_fk_categorie (fk_categorie); -ALTER TABLE llx_categorie_entrepot ADD INDEX idx_categorie_entrepot_fk_entrepot (fk_entrepot); +ALTER TABLE llx_categorie_warehouse ADD PRIMARY KEY pk_categorie_warehouse (fk_categorie, fk_warehouse); +ALTER TABLE llx_categorie_warehouse ADD INDEX idx_categorie_warehouse_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_warehouse ADD INDEX idx_categorie_warehouse_fk_warehouse (fk_warehouse); -ALTER TABLE llx_categorie_entrepot ADD CONSTRAINT fk_categorie_entrepot_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); -ALTER TABLE llx_categorie_entrepot ADD CONSTRAINT fk_categorie_entrepot_fk_entrepot_rowid FOREIGN KEY (fk_entrepot) REFERENCES llx_entrepot (rowid); +ALTER TABLE llx_categorie_warehouse ADD CONSTRAINT fk_categorie_warehouse_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_warehouse ADD CONSTRAINT fk_categorie_warehouse_fk_warehouse_rowid FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot (rowid); diff --git a/htdocs/install/mysql/tables/llx_categorie_stock.sql b/htdocs/install/mysql/tables/llx_categorie_warehouse.sql similarity index 94% rename from htdocs/install/mysql/tables/llx_categorie_stock.sql rename to htdocs/install/mysql/tables/llx_categorie_warehouse.sql index 92173d83a01..692b9be92af 100644 --- a/htdocs/install/mysql/tables/llx_categorie_stock.sql +++ b/htdocs/install/mysql/tables/llx_categorie_warehouse.sql @@ -19,9 +19,9 @@ -- -- ============================================================================ -create table llx_categorie_entrepot +create table llx_categorie_warehouse ( fk_categorie integer NOT NULL, - fk_entrepot integer NOT NULL, + fk_warehouse integer NOT NULL, import_key varchar(14) )ENGINE=innodb; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 647ffda194d..c8e472fb718 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5040,12 +5040,12 @@ class Product extends CommonObject // Process foreach($to_del as $del) { if ($c->fetch($del) > 0) { - $c->del_type($this, 'product'); + $c->del_type($this, Categorie::TYPE_PRODUCT); } } foreach ($to_add as $add) { if ($c->fetch($add) > 0) { - $c->add_type($this, 'product'); + $c->add_type($this, Categorie::TYPE_PRODUCT); } } diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index f8d9cee9634..c085bff8082 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -310,7 +310,7 @@ if ($action == 'create') if ($conf->categorie->enabled) { // Categories print '