From e24a8b45052b2a92ea7ca3ab26f46a22aeed0a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 20 May 2015 16:43:44 +0200 Subject: [PATCH 1/4] Closed bug #2843 Wrong SQL table called --- htdocs/categories/class/categorie.class.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 96949371bae..4ebf6126deb 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -472,7 +472,7 @@ class Categorie extends CommonObject * Link an object to the category * * @param Object $obj Object to link to category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $type Type of category ('societe', 'member', 'customer', 'supplier', 'product', 'contact') * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ function add_type($obj,$type) @@ -488,9 +488,20 @@ class Categorie extends CommonObject if ($type == 'customer') $type='societe'; if ($type == 'supplier') $type='fournisseur'; - $column_name=$type; - if ($type=='contact') $column_name='socpeople'; - if ($type=='fournisseur') $column_name='societe'; + /** + * llx_categorie_contact => fk_socpeople + * llx_categorie_fournisseur, llx_categorie_societe => fk_soc + * llx_categorie_member => fk_member + * llx_categorie_product => fk_product + * llx_categories_extrafields => fk_object + */ + if ($type == 'contact') { + $column_name = 'socpeople'; + } elseif ($type == 'supplier' || ($type == 'societe')) { + $column_name = 'soc'; + } else { + $column_name = 'type'; + } $this->db->begin(); From 9ebae9520a72805b88aa91898d0081ccdc56b6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 20 May 2015 16:46:12 +0200 Subject: [PATCH 2/4] Extrafields does not form part of this class --- htdocs/categories/class/categorie.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 4ebf6126deb..b5e46cc475a 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -493,7 +493,6 @@ class Categorie extends CommonObject * llx_categorie_fournisseur, llx_categorie_societe => fk_soc * llx_categorie_member => fk_member * llx_categorie_product => fk_product - * llx_categories_extrafields => fk_object */ if ($type == 'contact') { $column_name = 'socpeople'; From 8627f2f19b5551beb1de040e0c7f4f7ba7487e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 25 May 2015 14:01:15 +0200 Subject: [PATCH 3/4] Removed innecesary test --- htdocs/categories/class/categorie.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b5e46cc475a..67d821578dd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -472,7 +472,7 @@ class Categorie extends CommonObject * Link an object to the category * * @param Object $obj Object to link to category - * @param string $type Type of category ('societe', 'member', 'customer', 'supplier', 'product', 'contact') + * @param string $type Type of category ('societe', 'member', 'product', 'contact', 'fournisseur) * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ function add_type($obj,$type) @@ -485,8 +485,8 @@ class Categorie extends CommonObject // For backward compatibility if ($type == 'company') $type='societe'; - if ($type == 'customer') $type='societe'; - if ($type == 'supplier') $type='fournisseur'; + elseif ($type == 'customer') $type='societe'; + elseif ($type == 'supplier') $type='fournisseur'; /** * llx_categorie_contact => fk_socpeople @@ -496,7 +496,7 @@ class Categorie extends CommonObject */ if ($type == 'contact') { $column_name = 'socpeople'; - } elseif ($type == 'supplier' || ($type == 'societe')) { + } elseif ($type == 'fournisseur' || ($type == 'societe')) { $column_name = 'soc'; } else { $column_name = 'type'; From c0346bcba43a94e4e26b7962fe9355e886cdbe1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 25 May 2015 14:59:34 +0200 Subject: [PATCH 4/4] Fixed typo --- htdocs/categories/class/categorie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 67d821578dd..cd248d45744 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -499,7 +499,7 @@ class Categorie extends CommonObject } elseif ($type == 'fournisseur' || ($type == 'societe')) { $column_name = 'soc'; } else { - $column_name = 'type'; + $column_name = $type; } $this->db->begin();