Fix: on exclus le contact de la liste déroulante lorsqu'il est sélectionné
This commit is contained in:
parent
55e8189b23
commit
125ce2dca6
@ -220,7 +220,17 @@ if ($id > 0)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td colspan="1">';
|
print '<td colspan="1">';
|
||||||
$html->select_users($user->id,'contactid');
|
// On récupère les id des users déjà sélectionnés
|
||||||
|
$userAlreadySelected = array();
|
||||||
|
$tab = $propal->liste_contact(-1,'internal');
|
||||||
|
$num=sizeof($tab);
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$userAlreadySelected[$i] = $tab[$i]['id'];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$html->select_users($user->id,'contactid',0,$userAlreadySelected);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$propal->selectTypeContact($propal, '', 'type','internal');
|
$propal->selectTypeContact($propal, '', 'type','internal');
|
||||||
@ -249,7 +259,17 @@ if ($id > 0)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td colspan="1">';
|
print '<td colspan="1">';
|
||||||
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid');
|
// On récupère les id des contacts déjà sélectionnés
|
||||||
|
$contactAlreadySelected = array();
|
||||||
|
$tab = $propal->liste_contact(-1,'external');
|
||||||
|
$num=sizeof($tab);
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$contactAlreadySelected[$i] = $tab[$i]['id'];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$propal->selectTypeContact($propal, '', 'type','external');
|
$propal->selectTypeContact($propal, '', 'type','external');
|
||||||
|
|||||||
@ -790,14 +790,23 @@ class Form
|
|||||||
* \param socid Id de la société
|
* \param socid Id de la société
|
||||||
* \param selected Id contact pré-sélectionn
|
* \param selected Id contact pré-sélectionn
|
||||||
* \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 exclude Liste des id contacts à exclure
|
||||||
* \return int <0 si ko, >=0 si ok
|
* \return int <0 si ko, >=0 si ok
|
||||||
*/
|
*/
|
||||||
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0)
|
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='')
|
||||||
{
|
{
|
||||||
|
// Permettre l'exclusion de contacts
|
||||||
|
if (is_array($exclude))
|
||||||
|
{
|
||||||
|
$excludeContacts = implode("','",$exclude);
|
||||||
|
}
|
||||||
|
|
||||||
// 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 fk_soc=".$socid;
|
||||||
|
if (is_array($exclude) && $excludeContacts) $sql.= " AND s.rowid NOT IN ('".$excludeContacts."')";
|
||||||
$sql.= " ORDER BY s.name ASC";
|
$sql.= " ORDER BY s.name ASC";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
@ -815,7 +824,6 @@ class Form
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object();
|
$obj = $this->db->fetch_object();
|
||||||
|
|
||||||
if ($htmlname != 'none')
|
if ($htmlname != 'none')
|
||||||
{
|
{
|
||||||
if ($selected && $selected == $obj->rowid)
|
if ($selected && $selected == $obj->rowid)
|
||||||
@ -849,12 +857,21 @@ class Form
|
|||||||
* \brief Retourne la liste déroulante des utilisateurs
|
* \brief Retourne la liste déroulante des utilisateurs
|
||||||
* \param selected Id contact pré-sélectionn
|
* \param selected Id contact pré-sélectionn
|
||||||
* \param htmlname Nom champ formulaire
|
* \param htmlname Nom champ formulaire
|
||||||
|
* \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
|
||||||
|
* \param exclude Liste des id utilisateurs à exclure
|
||||||
*/
|
*/
|
||||||
function select_users($selected='',$htmlname='userid',$show_empty=0)
|
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='')
|
||||||
{
|
{
|
||||||
|
// Permettre l'exclusion d'utilisateurs
|
||||||
|
if (is_array($exclude))
|
||||||
|
{
|
||||||
|
$excludeUsers = implode("','",$exclude);
|
||||||
|
}
|
||||||
|
|
||||||
// On recherche les utilisateurs
|
// On recherche les utilisateurs
|
||||||
$sql = "SELECT u.rowid, u.name, u.firstname FROM ";
|
$sql = "SELECT u.rowid, u.name, u.firstname FROM ";
|
||||||
$sql.= MAIN_DB_PREFIX ."user as u";
|
$sql.= MAIN_DB_PREFIX ."user as u";
|
||||||
|
if (is_array($exclude) && $excludeUsers) $sql.= " WHERE u.rowid NOT IN ('".$excludeUsers."')";
|
||||||
$sql.= " ORDER BY u.name ASC";
|
$sql.= " ORDER BY u.name ASC";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user