Fix: bad request

This commit is contained in:
Regis Houssin 2011-06-16 08:55:59 +00:00
parent 21c9cc205c
commit b22a7ce335

View File

@ -946,18 +946,15 @@ class Form
} }
if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype; if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype;
// Add criteria on ref/label // Add criteria on ref/label
if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) // Can use index
{
if ($filterkey && $filterkey != '') if ($filterkey && $filterkey != '')
{
if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) // Can use index
{ {
$sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'"; $sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'";
if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '".$filterkey."%'"; if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '".$filterkey."%'";
$sql.=")"; $sql.=")";
} }
}
else else
{
if ($filterkey && $filterkey != '')
{ {
$sql.=" AND (p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%'"; $sql.=" AND (p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%'";
if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '%".$filterkey."%'"; if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '%".$filterkey."%'";
@ -1175,13 +1172,16 @@ class Form
if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype; if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype;
if (! empty($filtre)) $sql.=" ".$filtre; if (! empty($filtre)) $sql.=" ".$filtre;
// Add criteria on ref/label // Add criteria on ref/label
if ($filterkey && $filterkey != '')
{
if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
{ {
if ($filterkey && $filterkey != '') $sql.=" AND (pf.ref_fourn like '%".$filterkey."%' OR p.ref like '%".$filterkey."%' OR p.label like '%".$filterkey."%')"; $sql.=" AND (pf.ref_fourn LIKE '".$filterkey."%' OR p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%')";
} }
else else
{ {
if ($filterkey && $filterkey != '') $sql.=" AND (pf.ref_fourn like '".$filterkey."%' OR p.ref like '".$filterkey."%' OR p.label like '".$filterkey."%')"; $sql.=" AND (pf.ref_fourn LIKE '%".$filterkey."%' OR p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%')";
}
} }
$sql.= " ORDER BY pf.ref_fourn DESC"; $sql.= " ORDER BY pf.ref_fourn DESC";