From df5a009aa2e27d33cc8913059e2a4a176f1f7f9c Mon Sep 17 00:00:00 2001 From: Cedric <c.gross@kreiz-it.fr> Date: Tue, 1 Apr 2014 16:21:20 +0200 Subject: [PATCH] FIX : [ bug #1317 ] Removing a category does not remove all child categories --- htdocs/categories/class/categorie.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 81ea914e481..dbbfc83b8ea 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -292,6 +292,20 @@ class Categorie $this->db->begin(); + /* FIX #1317 : Check for child cat and move up 1 level*/ + if (! $error) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; + $sql.= " SET fk_parent = ".$this->fk_parent; + $sql.= " WHERE fk_parent = ".$this->id; + + if (!$this->db->query($sql)) + { + $this->error=$this->db->lasterror(); + dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR); + $error++; + } + } if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_societe"; -- GitLab