From 3f23b116c6a5f58d4fad3b9b1f0acb8408066382 Mon Sep 17 00:00:00 2001
From: Florian HENRY <florian.henry@open-concept.pro>
Date: Fri, 11 Jul 2014 11:44:54 +0200
Subject: [PATCH] =?UTF-8?q?[=20bug=20#1522=20]=20Liste=20des=20proposition?=
 =?UTF-8?q?s=20commerciales=20non=20filt=C3=A9e=20depuis=20un=20projet?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 htdocs/core/class/html.formprojet.class.php | 7 ++++---
 htdocs/projet/element.php                   | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index b3228278261..7b8eefdbbae 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -164,9 +164,10 @@ class FormProjets
 	 *    Build Select List of element associable to a project
 	 *
 	 *    @param	string	$table_element		Table of the element to update
+	 *    @param	int		$socid				socid to filter
 	 *    @return	string						The HTML select list of element
 	 */
-	function select_element($table_element)
+	function select_element($table_element,$socid=0)
 	{
 		global $conf;
 
@@ -193,8 +194,8 @@ class FormProjets
 
 		$sql.= " FROM ".MAIN_DB_PREFIX.$table_element;
 		$sql.= " WHERE ".$projectkey." is null";
-		if (!empty($this->societe->id)) {
-			$sql.= " AND fk_soc=".$this->societe->id;
+		if (!empty($socid)) {
+			$sql.= " AND fk_soc=".$socid;
 		}
 		$sql.= ' AND entity='.getEntity('project');
 		$sql.= " ORDER BY ref DESC";
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 88330819349..4075113d625 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -216,7 +216,7 @@ foreach ($listofreferent as $key => $value)
 
 		print_titre($langs->trans($title));
 		
-		$selectList=$formproject->select_element($tablename);
+		$selectList=$formproject->select_element($tablename,$project->societe->id);
 		if ($selectList<0) {
 			setEventMessage($formproject->error,'errors');
 		}
-- 
GitLab