// We'll need this table joined to the select in order to filter by categ
// 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.=') ';
$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).')';
$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($search_categ)$sql.=" AND p.rowid = cp.fk_product";// Join for the needed table to filter by categ
if($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)."%')";
{
$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 the type is not 1, we show all products (type = 0,2,3)