New: Extend capabilities of select_contacts

This commit is contained in:
Laurent Destailleur 2011-02-09 19:22:40 +00:00
parent c595f43412
commit b365a431ae

View File

@ -669,17 +669,19 @@ class Form
/** /**
* \brief Retourne la liste deroulante des contacts d'une societe donnee * Return list of all contacts (for a third party or all)
* \param socid Id de la societe * @param socid Id ot third party or 0 for all
* \param selected Id contact pre-selectionne * @param selected Id contact pre-selectionne
* \param htmlname Nom champ formulaire ('none' pour champ non editable) * @param htmlname Nom champ formulaire ('none' pour champ non editable)
* \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue * @param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* \param exclude Liste des id contacts a exclure * @param exclude Liste des id contacts a exclure
* \param limitto Disable answers that are not id in this array list * @param limitto Disable answers that are not id in this array list
* \return int <0 if KO, Nb of contact in list if OK * @return int <0 if KO, Nb of contact in list if OK
*/ */
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='') function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='')
{ {
global $conf;
// Permettre l'exclusion de contacts // Permettre l'exclusion de contacts
if (is_array($exclude)) if (is_array($exclude))
{ {
@ -689,7 +691,8 @@ class Form
// On recherche les societes // On recherche les societes
$sql = "SELECT s.rowid, s.name, s.firstname FROM"; $sql = "SELECT s.rowid, s.name, s.firstname FROM";
$sql.= " ".MAIN_DB_PREFIX ."socpeople as s"; $sql.= " ".MAIN_DB_PREFIX ."socpeople as s";
$sql.= " WHERE fk_soc=".$socid; $sql.= " WHERE entity = ".$conf->entity;
if ($socid) $sql.= " AND fk_soc=".$socid;
if (is_array($exclude) && $excludeContacts) $sql.= " AND s.rowid NOT IN ('".$excludeContacts."')"; if (is_array($exclude) && $excludeContacts) $sql.= " AND s.rowid NOT IN ('".$excludeContacts."')";
$sql.= " ORDER BY s.name ASC"; $sql.= " ORDER BY s.name ASC";
@ -700,7 +703,7 @@ class Form
$num=$this->db->num_rows($resql); $num=$this->db->num_rows($resql);
if ($num == 0) return 0; if ($num == 0) return 0;
if ($htmlname != 'none') print '<select class="flat" name="'.$htmlname.'">'; if ($htmlname != 'none') print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
if ($showempty) print '<option value="0">&nbsp;</option>'; if ($showempty) print '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;