diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index 56dc24c2941..06c3741b476 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -155,16 +155,18 @@ class Categorie { $sql = 'delete from '.MAIN_DB_PREFIX.'categorie_association'; $sql .= ' WHERE fk_categorie_mere = "'.$this->id.'" or fk_categorie_fille = "'.$this->id.'"'; + if (! $this->db->query($sql)) { dolibarr_print_error($this->db); return -1; } - if($this->id_mere !="") + if($this->id_mere !="" && $this->id_mere!=$this->id) { $sql = 'insert into '.MAIN_DB_PREFIX.'categorie_association(fk_categorie_mere,fk_categorie_fille)'; $sql .= ' VALUES ("'.$this->id_mere.'","'.$this->id.'")'; + print $sql; if (! $this->db->query($sql)) { dolibarr_print_error($this->db); diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 28272a38a2b..b730d79b408 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -42,6 +42,8 @@ if ($_POST["action"] == 'update' && $user->rights->categorie->creer) $categorie->description = $_POST["description"]; if($_POST['catMere'] != "-1") $categorie->id_mere = $_POST['catMere']; + else + $categorie->id_mere = ""; if (!$categorie->label || !$categorie->description)