forked from Wavyzz/dolibarr
Fix #25171 : add method getContacts in Societe class to retrieve contacts of a societe
This commit is contained in:
@@ -5286,10 +5286,8 @@ class Societe extends CommonObject
|
|||||||
* @param string $element Filter on this element of default contact type ('facture', 'propal', 'commande' ...)
|
* @param string $element Filter on this element of default contact type ('facture', 'propal', 'commande' ...)
|
||||||
* @return array|int Array of contacts, -1 if error
|
* @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
|
// phpcs:enable
|
||||||
global $langs;
|
global $langs;
|
||||||
@@ -5305,9 +5303,6 @@ class Societe extends CommonObject
|
|||||||
$sql .= " FROM ".$this->db->prefix()."c_type_contact tc";
|
$sql .= " FROM ".$this->db->prefix()."c_type_contact tc";
|
||||||
$sql .= ", ".$this->db->prefix()."societe_contacts sc";
|
$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 .= " LEFT JOIN ".$this->db->prefix()."socpeople t on sc.fk_socpeople = t.rowid";
|
||||||
|
|
||||||
$sql .= " WHERE sc.fk_soc = ".((int) $this->id);
|
$sql .= " WHERE sc.fk_soc = ".((int) $this->id);
|
||||||
@@ -5319,14 +5314,12 @@ class Societe extends CommonObject
|
|||||||
$sql .= " AND tc.code = '".$this->db->escape($code)."'";
|
$sql .= " AND tc.code = '".$this->db->escape($code)."'";
|
||||||
}
|
}
|
||||||
$sql .= " AND sc.entity = ".getEntity($this->element);
|
$sql .= " AND sc.entity = ".getEntity($this->element);
|
||||||
|
|
||||||
$sql .= " AND tc.source = 'external'";
|
$sql .= " AND tc.source = 'external'";
|
||||||
|
|
||||||
$sql .= " AND tc.active=1";
|
$sql .= " AND tc.active=1";
|
||||||
|
|
||||||
$sql .= " ORDER BY t.lastname ASC";
|
$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);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
|
|||||||
Reference in New Issue
Block a user