From 3d0d2053bb428416561da172bb7218db8162f3e7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 1 Apr 2010 08:47:41 +0000 Subject: [PATCH] Fix: limited to a certain status --- htdocs/core/commonobject.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/commonobject.class.php b/htdocs/core/commonobject.class.php index 9b7d29a4eb9..55312cd20cd 100644 --- a/htdocs/core/commonobject.class.php +++ b/htdocs/core/commonobject.class.php @@ -296,21 +296,24 @@ class CommonObject * Exemple: contact interne suivi paiement ('internal', 'SALESREPFOLL') * \param source 'external' or 'internal' * \param code 'BILLING', 'SHIPPING', 'SALESREPFOLL', ... + ** \param status limited to a certain status * \return array Liste des id contacts */ - function getIdContact($source,$code) + function getIdContact($source,$code,$status=0) { $result=array(); $i=0; $sql = "SELECT ec.fk_socpeople"; - $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec"; + $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " WHERE ec.element_id = ".$this->id; - $sql.= " AND ec.fk_c_type_contact=tc.rowid"; + $sql.= " AND ec.fk_c_type_contact = tc.rowid"; $sql.= " AND tc.element = '".$this->element."'"; $sql.= " AND tc.source = '".$source."'"; $sql.= " AND tc.code = '".$code."'"; $sql.= " AND tc.active = 1"; + if ($status) $sql.= " AND ec.statut = ".$status; dol_syslog("CommonObject::getIdContact sql=".$sql); $resql=$this->db->query($sql);