Rename table for categorie of warehouses
This commit is contained in:
parent
a79c4608d6
commit
6858dce344
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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);
|
||||
@ -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;
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -310,7 +310,7 @@ if ($action == 'create')
|
||||
if ($conf->categorie->enabled) {
|
||||
// Categories
|
||||
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_STOCK, '', 'parent', 64, 0, 1);
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE, '', 'parent', 64, 0, 1);
|
||||
print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, '', 0, '100%');
|
||||
print "</td></tr>";
|
||||
}
|
||||
@ -454,7 +454,7 @@ else
|
||||
// Categories
|
||||
if($conf->categorie->enabled) {
|
||||
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||
print $form->showCategories($object->id, 'stock', 1);
|
||||
print $form->showCategories($object->id, 'warehouse', 1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
@ -732,9 +732,9 @@ else
|
||||
if ($conf->categorie->enabled)
|
||||
{
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_STOCK, '', 'parent', 64, 0, 1);
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE, '', 'parent', 64, 0, 1);
|
||||
$c = new Categorie($db);
|
||||
$cats = $c->containing($object->id, Categorie::TYPE_STOCK);
|
||||
$cats = $c->containing($object->id, Categorie::TYPE_WAREHOUSE);
|
||||
$arrayselected=array();
|
||||
foreach($cats as $cat) {
|
||||
$arrayselected[] = $cat->id;
|
||||
|
||||
@ -856,7 +856,9 @@ class Entrepot extends CommonObject
|
||||
*/
|
||||
public function setCategories($categories)
|
||||
{
|
||||
// Handle single category
|
||||
$type_categ = Categorie::TYPE_WAREHOUSE;
|
||||
|
||||
// Handle single category
|
||||
if (! is_array($categories)) {
|
||||
$categories = array($categories);
|
||||
}
|
||||
@ -864,7 +866,7 @@ class Entrepot extends CommonObject
|
||||
// Get current categories
|
||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||
$c = new Categorie($this->db);
|
||||
$existing = $c->containing($this->id, Categorie::TYPE_STOCK, 'id');
|
||||
$existing = $c->containing($this->id, $type_categ, 'id');
|
||||
|
||||
// Diff
|
||||
if (is_array($existing)) {
|
||||
@ -878,12 +880,12 @@ class Entrepot extends CommonObject
|
||||
// Process
|
||||
foreach($to_del as $del) {
|
||||
if ($c->fetch($del) > 0) {
|
||||
$c->del_type($this, 'stock');
|
||||
$c->del_type($this, $type_categ);
|
||||
}
|
||||
}
|
||||
foreach ($to_add as $add) {
|
||||
if ($c->fetch($add) > 0) {
|
||||
$c->add_type($this, 'stock');
|
||||
$c->add_type($this, $type_categ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1979,10 +1979,7 @@ class Project extends CommonObject
|
||||
*/
|
||||
public function setCategories($categories)
|
||||
{
|
||||
// Decode type
|
||||
$type_id = Categorie::TYPE_PROJECT;
|
||||
$type_text = 'project';
|
||||
|
||||
$type_categ = Categorie::TYPE_PROJECT;
|
||||
|
||||
// Handle single category
|
||||
if (!is_array($categories)) {
|
||||
@ -1992,7 +1989,7 @@ class Project extends CommonObject
|
||||
// Get current categories
|
||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||
$c = new Categorie($this->db);
|
||||
$existing = $c->containing($this->id, $type_id, 'id');
|
||||
$existing = $c->containing($this->id, $type_categ, 'id');
|
||||
|
||||
// Diff
|
||||
if (is_array($existing)) {
|
||||
@ -2006,7 +2003,7 @@ class Project extends CommonObject
|
||||
// Process
|
||||
foreach ($to_del as $del) {
|
||||
if ($c->fetch($del) > 0) {
|
||||
$result=$c->del_type($this, $type_text);
|
||||
$result=$c->del_type($this, $type_categ);
|
||||
if ($result<0) {
|
||||
$this->errors=$c->errors;
|
||||
$this->error=$c->error;
|
||||
@ -2016,7 +2013,7 @@ class Project extends CommonObject
|
||||
}
|
||||
foreach ($to_add as $add) {
|
||||
if ($c->fetch($add) > 0) {
|
||||
$result=$c->add_type($this, $type_text);
|
||||
$result=$c->add_type($this, $type_categ);
|
||||
if ($result<0) {
|
||||
$this->errors=$c->errors;
|
||||
$this->error=$c->error;
|
||||
|
||||
@ -4037,22 +4037,16 @@ class Societe extends CommonObject
|
||||
* Existing categories are left untouch.
|
||||
*
|
||||
* @param int[]|int $categories Category ID or array of Categories IDs
|
||||
* @param string $type Category type ('customer' or 'supplier')
|
||||
* @param string $type_categ Category type ('customer' or 'supplier')
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function setCategories($categories, $type)
|
||||
public function setCategories($categories, $type_categ)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||
|
||||
// Decode type
|
||||
if ($type == 'customer') {
|
||||
$type_id = Categorie::TYPE_CUSTOMER;
|
||||
$type_text = 'customer';
|
||||
} elseif ($type == 'supplier') {
|
||||
$type_id = Categorie::TYPE_SUPPLIER;
|
||||
$type_text = 'supplier';
|
||||
} else {
|
||||
dol_syslog(__METHOD__ . ': Type ' . $type . 'is an unknown company category type. Done nothing.', LOG_ERR);
|
||||
if (! in_array($type_categ, array(Categorie::TYPE_CUSTOMER, Categorie::TYPE_SUPPLIER))) {
|
||||
dol_syslog(__METHOD__ . ': Type ' . $type_categ . 'is an unknown company category type. Done nothing.', LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -4063,7 +4057,7 @@ class Societe extends CommonObject
|
||||
|
||||
// Get current categories
|
||||
$c = new Categorie($this->db);
|
||||
$existing = $c->containing($this->id, $type_id, 'id');
|
||||
$existing = $c->containing($this->id, $type_categ, 'id');
|
||||
|
||||
// Diff
|
||||
if (is_array($existing)) {
|
||||
@ -4079,13 +4073,13 @@ class Societe extends CommonObject
|
||||
// Process
|
||||
foreach ($to_del as $del) {
|
||||
if ($c->fetch($del) > 0) {
|
||||
$c->del_type($this, $type_text);
|
||||
$c->del_type($this, $type_categ);
|
||||
}
|
||||
}
|
||||
foreach ($to_add as $add) {
|
||||
if ($c->fetch($add) > 0)
|
||||
{
|
||||
$result = $c->add_type($this, $type_text);
|
||||
$result = $c->add_type($this, $type_categ);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
|
||||
@ -997,6 +997,8 @@ class User extends CommonObject
|
||||
*/
|
||||
public function setCategories($categories)
|
||||
{
|
||||
$type_categ = Categorie::TYPE_USER;
|
||||
|
||||
// Handle single category
|
||||
if (!is_array($categories)) {
|
||||
$categories = array($categories);
|
||||
@ -1005,7 +1007,7 @@ class User extends CommonObject
|
||||
// Get current categories
|
||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||
$c = new Categorie($this->db);
|
||||
$existing = $c->containing($this->id, Categorie::TYPE_USER, 'id');
|
||||
$existing = $c->containing($this->id, $type_categ, 'id');
|
||||
|
||||
// Diff
|
||||
if (is_array($existing)) {
|
||||
@ -1019,12 +1021,12 @@ class User extends CommonObject
|
||||
// Process
|
||||
foreach ($to_del as $del) {
|
||||
if ($c->fetch($del) > 0) {
|
||||
$c->del_type($this, 'user');
|
||||
$c->del_type($this, $type_categ);
|
||||
}
|
||||
}
|
||||
foreach ($to_add as $add) {
|
||||
if ($c->fetch($add) > 0) {
|
||||
$c->add_type($this, 'user');
|
||||
$c->add_type($this, $type_categ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user