From 3e9af3ad8bd5e87efcda33b13d4f2fa0b4760c20 Mon Sep 17 00:00:00 2001 From: vmaury Date: Fri, 23 Jun 2023 09:53:40 +0200 Subject: [PATCH] Fix #25171 : add method getContacts in Societe class to retrieve contacts of a societe --- htdocs/societe/class/societe.class.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 92aa59e8600..7d438ec1d4e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -5285,11 +5285,9 @@ class Societe extends CommonObject * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) * @param string $element Filter on this element of default contact type ('facture', 'propal', 'commande' ...) * @return array|int Array of contacts, -1 if error - * * - * */ - function liste_contact_societe($list = 0, $code = '', $element = '') + function getContacts($list = 0, $code = '', $element = '') { // phpcs:enable global $langs; @@ -5305,9 +5303,6 @@ class Societe extends CommonObject $sql .= " FROM ".$this->db->prefix()."c_type_contact tc"; $sql .= ", ".$this->db->prefix()."societe_contacts sc"; -// fk_soc ↓ = -// fk_c_type_contact fk_socpeople tms import_key - $sql .= " LEFT JOIN ".$this->db->prefix()."socpeople t on sc.fk_socpeople = t.rowid"; $sql .= " WHERE sc.fk_soc = ".((int) $this->id); @@ -5318,15 +5313,13 @@ class Societe extends CommonObject if ($code) { $sql .= " AND tc.code = '".$this->db->escape($code)."'"; } - $sql .= " AND sc.entity = ".getEntity($this->element); - - $sql .= " AND tc.source = 'external'"; - + $sql .= " AND sc.entity = ".getEntity($this->element); + $sql .= " AND tc.source = 'external'"; $sql .= " AND tc.active=1"; $sql .= " ORDER BY t.lastname ASC"; - dol_syslog(get_class($this)."::liste_contact_societe", LOG_DEBUG); + dol_syslog(get_class($this)."::getContacts", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql);