diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 1112d34d13f..6c2b5600917 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -446,7 +446,7 @@ class FormProjets
* Build a HTML select list of element of same thirdparty to suggest to link them to project
*
* @param string $table_element Table of the element to update
- * @param int $socid If of thirdparty to use as filter
+ * @param string $socid If of thirdparty to use as filter or 'id1,id2,...'
* @param string $morecss More CSS
* @param int $limitonstatus Add filters to limit length of list to opened status (for example to avoid ERR_RESPONSE_HEADERS_TOO_BIG on project/element.php page). TODO To implement
* @return int|string The HTML select list of element or '' if nothing or -1 if KO
@@ -502,7 +502,11 @@ class FormProjets
$sql.= " FROM ".MAIN_DB_PREFIX.$table_element." as t";
if ($linkedtothirdparty) $sql.=", ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE ".$projectkey." is null";
- if (! empty($socid) && $linkedtothirdparty) $sql.= " AND t.fk_soc=".$socid;
+ if (! empty($socid) && $linkedtothirdparty)
+ {
+ if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid;
+ else $sql.= " AND t.fk_soc IN (".$socid.")";
+ }
if (! in_array($table_element, array('expensereport_det'))) $sql.= ' AND t.entity IN ('.getEntity('project',1).')';
if ($linkedtothirdparty) $sql.=" AND s.rowid = t.fk_soc";
if ($sqlfilter) $sql.= " AND ".$sqlfilter;
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 2da7a6e5227..710807dcdec 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -640,9 +640,14 @@ foreach ($listofreferent as $key => $value)
$addform='';
$idtofilterthirdparty=0;
- if (! in_array($tablename, array('facture_fourn', 'commande_fournisseur'))) $idtofilterthirdparty=$object->thirdparty->id;
+ $array_of_element_linkable_with_different_thirdparty = array('facture_fourn', 'commande_fournisseur');
+ if (! in_array($tablename, $array_of_element_linkable_with_different_thirdparty))
+ {
+ $idtofilterthirdparty=$object->thirdparty->id;
+ if (! empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty.=','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS;
+ }
- if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty > 0)
+ if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty)
{
$selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300');
if (! $selectList || ($selectList<0))