From 34d4c15d0eed06f7abccfb590d8f0fdb50361afa Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Thu, 5 Sep 2013 21:03:03 +0200 Subject: [PATCH] Fix bug on category contact --- htdocs/contact/class/contact.class.php | 16 ++++++++++++++++ htdocs/contact/list.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 0a25bbf8028..cbd4cf122f4 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -723,6 +723,22 @@ class Contact extends CommonObject } } + if (! $error) + { + // Remove category + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople = ".$rowid; + dol_syslog(get_class($this)."::delete sql=".$sql); + $resql=$this->db->query($sql); + if (! $resql) + { + $error++; + $this->error .= $this->db->lasterror(); + $errorflag=-1; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); + + } + } + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople"; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 19b389cc192..e12b34b78a7 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -122,7 +122,7 @@ $sql.= " cp.code as country_code"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as cp ON cp.rowid = p.fk_pays"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; -if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cs ON s.rowid = cs.fk_socpeople"; // We need this table joined to the select in order to filter by categ +if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cs ON p.rowid = cs.fk_socpeople"; // We need this table joined to the select in order to filter by categ if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= ' WHERE p.entity IN ('.getEntity('societe', 1).')'; if (!$user->rights->societe->client->voir && !$socid) //restriction