diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index aef2289ab2e..bc8ba64b14b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -451,9 +451,10 @@ abstract class CommonObject * @param string $source 'internal', 'external' or 'all' * @param string $order Sort order by : 'code' or 'rowid' * @param string $option 0=Return array id->label, 1=Return array code->label + * @param string $activeonly 0=all type of contact, 1=only the active * @return array Array list of type of contacts (id->label if option=0, code->label if option=1) */ - function liste_type_contact($source='internal', $order='code', $option=0) + function liste_type_contact($source='internal', $order='code', $option=0, $activeonly=0) { global $langs; @@ -461,6 +462,9 @@ abstract class CommonObject $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " WHERE tc.element='".$this->element."'"; + if ($activeonly == 1) + $sql.= " AND tc.active=1"; // only the active type + if (! empty($source)) $sql.= " AND tc.source='".$source."'"; $sql.= " ORDER by tc.".$order; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 97a0c9e9f26..a6210be79c6 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -627,7 +627,7 @@ class FormCompany { if (is_object($object) && method_exists($object, 'liste_type_contact')) { - $lesTypes = $object->liste_type_contact($source, $order); + $lesTypes = $object->liste_type_contact($source, $order, 0, 1); print '