diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 9cbb86cf017..4a0d966b6d2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -704,7 +704,7 @@ class Adherent extends CommonObject $this->db->begin(); - // Suppression options + // Remove extrafields $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_extrafields WHERE fk_object = ".$rowid; dol_syslog(get_class($this)."::delete sql=".$sql); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9e12a508db5..6a43e5e4396 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1041,9 +1041,22 @@ class Societe extends CommonObject } } - // Remove third party + // Remove extrafields if (! $error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_extrafields WHERE fk_object = ".$id; + dol_syslog(get_class($this)."::delete sql=".$sql); + if (! $this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); + } + } + + // Remove third party + if (! $error) + { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE rowid = " . $id; dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); @@ -1051,7 +1064,7 @@ class Societe extends CommonObject { $error++; $this->error = $this->db->lasterror(); - dol_syslog(get_class($this)."::delete erreur -3 ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } } @@ -2569,7 +2582,7 @@ class Societe extends CommonObject $this->idprof5='idprof5'; $this->idprof6='idprof6'; } - + /** * Check if localtax define for company * Used to build previews or test instances. @@ -2580,11 +2593,11 @@ class Societe extends CommonObject */ function hasLocalTax($localTaxNum) { global $user,$langs,$conf; - + // check parameter if ($localTaxNum != 1 && $localTaxNum != 2) return false; - + // Search local taxes $sql = "SELECT t.localtax1, t.localtax2"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; @@ -2600,7 +2613,7 @@ class Societe extends CommonObject if ($resql) { return ($this->db->num_rows($resql) > 0); - + } else return false; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index abf8ef515c8..4e335e34956 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -689,33 +689,61 @@ class User extends CommonObject // Supprime droits $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id; - if ($this->db->query($sql)) + if (! $error && ! $this->db->query($sql)) { - + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this)."::delete error -1 ".$this->error, LOG_ERR); } // Remove group $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user WHERE fk_user = ".$this->id; - if ($this->db->query($sql)) + if (! $error && ! $this->db->query($sql)) { - + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this)."::delete error -2 ".$this->error, LOG_ERR); } // Si contact, supprime lien if ($this->contact_id) { $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user_creat = null WHERE rowid = ".$this->contact_id; - if ($this->db->query($sql)) + if (! $error && ! $this->db->query($sql)) { - + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); } } - // Supprime utilisateur - $sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = $this->id"; - $result = $this->db->query($sql); + // Remove extrafields + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_extrafields WHERE fk_object = ".$this->id; + dol_syslog(get_class($this)."::delete sql=".$sql); + if (! $this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } - if ($result) + // Remove user + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->id; + dol_syslog(get_class($this)."::delete sql=".$sql); + if (! $this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this)."::delete error -5 ".$this->error, LOG_ERR); + } + } + + if (! $error) { // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';