diff --git a/htdocs/societe/societe.php b/htdocs/societe/societe.php index f27de1eb33a..67d2d7bb46b 100644 --- a/htdocs/societe/societe.php +++ b/htdocs/societe/societe.php @@ -78,7 +78,7 @@ if ($mode == 'search') $sql = "SELECT s.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if ($search_sale || !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; @@ -127,7 +127,7 @@ if ($mode == 'search') { $sql.= "AND s.barcode LIKE '".$db->escape($crit)."'"; } - + $result=$db->query($sql); if ($result) { @@ -201,7 +201,7 @@ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_societe"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX."c_stcomm as st"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale || !$user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql.= " WHERE s.fk_stcomm = st.id";