From c8d6e9e44a37cc14143b40f661feff3306b3138e Mon Sep 17 00:00:00 2001
From: eldy <eldy@destailleur.fr>
Date: Sat, 23 Mar 2013 12:33:25 +0100
Subject: [PATCH] Fix: List of customers to build invoice or order

---
 htdocs/commande/fiche.php             | 2 +-
 htdocs/compta/facture.php             | 2 +-
 htdocs/contrat/fiche.php              | 2 +-
 htdocs/core/class/html.form.class.php | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 52b7761adbe..bb9c9117f24 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1487,7 +1487,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
 		else
 		{
 			print '<td colspan="2">';
-			print $form->select_company('','socid','s.client = 1',1);
+			print $form->select_company('','socid','s.client = 1 OR s.client = 3',1);
 			print '</td>';
 		}
 		print '</tr>'."\n";
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 96fca70af4c..77294a3c459 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1916,7 +1916,7 @@ if ($action == 'create')
     else
    {
    		print '<td colspan="2">';
-   		print $form->select_company('','socid','s.client = 1',1);
+   		print $form->select_company('','socid','s.client = 1 OR s.client = 3',1);
    		print '</td>';
     }
     print '</tr>'."\n";
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index 902dde79f17..de9ce68e6b3 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -827,7 +827,7 @@ if ($action == 'create')
 	else
 	{
 		print '<td colspan="2">';
-		print $form->select_company('','socid','s.client = 1',1);
+		print $form->select_company('','socid','s.client = 1 OR s.client = 3',1);
 		print '</td>';
 	}
 	print '</tr>'."\n";
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 941865da45a..4807ec768fa 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -678,7 +678,7 @@ class Form
         if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
         $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
         if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id;
-        if ($filter) $sql.= " AND ".$filter;
+        if ($filter) $sql.= " AND (".$filter.")";
         if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
         $sql.= " ORDER BY nom ASC";
 
-- 
GitLab