diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 9a7cfc78d574a7b5f2680764f28abf5f91c3666c..4338139e62c130edc856f086e261856972674462 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -127,21 +127,15 @@ else $sql.= ' p.fk_product_type, p.tms as datem,'; $sql.= ' p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte,'; $sql.= ' MIN(pfp.unitprice) as minsellprice'; - $sql.= ' FROM ('.MAIN_DB_PREFIX.'product as p'; + $sql.= ' FROM ('; // We'll need this table joined to the select in order to filter by categ - if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; + if ($search_categ) $sql.= MAIN_DB_PREFIX."categorie_product as cp, "; + $sql.= MAIN_DB_PREFIX.'product as p'; $sql.= ') '; - //if ($fourn_id > 0) // The DISTINCT is used to avoid duplicate from this link - //{ - //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; - //} + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ - if ($sall) - { - $sql.= " AND (p.ref LIKE '%".$db->escape($sall)."%' OR p.label LIKE '%".$db->escape($sall)."%' OR p.description LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%')"; - } + if ($sall) $sql.= " AND (p.ref LIKE '%".$db->escape($sall)."%' OR p.label LIKE '%".$db->escape($sall)."%' OR p.description LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%')"; // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) {