diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 51b7b92ea4e..71d86818180 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -426,47 +426,61 @@ class Form
/**
- * \brief Retourne la liste déroulante des contacts d'une société donnée
- * \param socid Id de la société
- * \param selected Id contact pré-sélectionn
- * \param htmlname Nom champ formulaire
+ * \brief Retourne la liste déroulante des contacts d'une société donnée
+ * \param socid Id de la société
+ * \param selected Id contact pré-sélectionn
+ * \param htmlname Nom champ formulaire ('none' pour champ non editable)
+ * \return int <0 si ko, >=0 si ok
*/
function select_contacts($socid,$selected='',$htmlname='contactid')
{
- // On recherche les societes
- $sql = "SELECT s.idp, s.name, s.firstname FROM ";
- $sql .= MAIN_DB_PREFIX ."socpeople as s";
- $sql .= " WHERE fk_soc=".$socid;
- $sql .= " ORDER BY s.name ASC";
-
- if ($this->db->query($sql))
- {
- print '';
- }
- else
- {
- dolibarr_print_error($this->db);
- }
+ // On recherche les societes
+ $sql = "SELECT s.idp, s.name, s.firstname FROM ";
+ $sql .= MAIN_DB_PREFIX ."socpeople as s";
+ $sql .= " WHERE fk_soc=".$socid;
+ $sql .= " ORDER BY s.name ASC";
+
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $num=$this->db->num_rows();
+ if ($num==0) return 0;
+
+ if ($htmlname != 'none') print '';
+ return 1;
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ return -1;
+ }
}
@@ -591,7 +605,7 @@ class Form
{
$objp = $this->db->fetch_object($result);
$opt = '