Fix: criteria of select
This commit is contained in:
parent
96286571e7
commit
49d65e5ebe
@ -1309,27 +1309,23 @@ class Form
|
|||||||
// Add criteria on ref/label
|
// Add criteria on ref/label
|
||||||
if ($filterkey != '')
|
if ($filterkey != '')
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) // Can use index
|
$sql.=' AND (';
|
||||||
|
$prefix=empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)?'%':''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
|
||||||
|
// For natural search
|
||||||
|
$scrit = explode(' ', $filterkey);
|
||||||
|
$i=0;
|
||||||
|
if (count($scrit) > 1) $sql.="(";
|
||||||
|
foreach ($scrit as $crit)
|
||||||
{
|
{
|
||||||
$sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'";
|
if ($i > 0) $sql.=" AND ";
|
||||||
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$filterkey."%'";
|
$sql.="(p.ref LIKE '".$prefix.$crit."%' OR p.label LIKE '".$prefix.$crit."%'";
|
||||||
|
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$prefix.$crit."%'";
|
||||||
$sql.=")";
|
$sql.=")";
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
else
|
if (count($scrit) > 1) $sql.=")";
|
||||||
{
|
if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$prefix.$filterkey."%'";
|
||||||
// For natural search
|
$sql.=')';
|
||||||
$scrit = explode(' ', $filterkey);
|
|
||||||
foreach ($scrit as $crit) {
|
|
||||||
$sql.=" AND (p.ref LIKE '%".$crit."%' OR p.label LIKE '%".$crit."%'";
|
|
||||||
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '%".$crit."%'";
|
|
||||||
$sql.=")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! empty($conf->barcode->enabled))
|
|
||||||
{
|
|
||||||
$sql .= " OR p.barcode LIKE '".$filterkey."'";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$sql.= $db->order("p.ref");
|
$sql.= $db->order("p.ref");
|
||||||
$sql.= $db->plimit($limit);
|
$sql.= $db->plimit($limit);
|
||||||
@ -1656,21 +1652,23 @@ 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 ($filterkey != '')
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
|
$sql.=' AND (';
|
||||||
{
|
$prefix=empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)?'%':''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
|
||||||
$sql.=" AND (pfp.ref_fourn LIKE '".$filterkey."%' OR p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%')";
|
// For natural search
|
||||||
}
|
$scrit = explode(' ', $filterkey);
|
||||||
else
|
$i=0;
|
||||||
{
|
if (count($scrit) > 1) $sql.="(";
|
||||||
$sql.=" AND (pfp.ref_fourn LIKE '%".$filterkey."%' OR p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%')";
|
foreach ($scrit as $crit)
|
||||||
}
|
{
|
||||||
|
if ($i > 0) $sql.=" AND ";
|
||||||
if (! empty($conf->barcode->enabled))
|
$sql.="(pfp.ref_fourn LIKE '".$prefix.$crit."%' OR p.ref LIKE '".$prefix.$crit."%' OR p.label LIKE '".$prefix.$crit."%')";
|
||||||
{
|
$i++;
|
||||||
$sql .= " OR p.barcode LIKE '".$filterkey."'";
|
}
|
||||||
}
|
if (count($scrit) > 1) $sql.=")";
|
||||||
|
if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$prefix.$filterkey."%'";
|
||||||
|
$sql.=')';
|
||||||
}
|
}
|
||||||
$sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
|
$sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user