From 42008fcf98d7fa90dc685fad4fe3a50be637f588 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 27 Oct 2014 10:22:21 +0100 Subject: [PATCH] Fix : remove associated users when company is deleted --- htdocs/societe/class/societe.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6d80189c7be..54e0edbf76a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1316,6 +1316,19 @@ class Societe extends CommonObject } } + // Remove associated users + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; + $sql.= " WHERE fk_soc = " . $id; + dol_syslog(get_class($this)."::Delete", LOG_DEBUG); + if (! $this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + } + } + // Removed extrafields if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used {