From bbae47c48f8647d542dfed205a1ff3d1465acc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Salvador?= Date: Wed, 4 Sep 2013 11:06:33 +0200 Subject: [PATCH] natural search --- htdocs/product/stock/replenish.php | 12 ++++++++++-- htdocs/product/stock/replenishorders.php | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 7eed3f2b13b..5e4835ec4ff 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -181,10 +181,18 @@ if (dol_strlen($type)) { } } if ($sref) { - $sql .= ' AND p.ref LIKE "%' . $sref . '%"'; + //natural search + $scrit = explode(' ', $sref); + foreach ($scrit as $crit) { + $sql .= ' AND p.ref LIKE "%' . $crit . '%"'; + } } if ($snom) { - $sql .= ' AND p.label LIKE "%' . $db->escape($snom) . '%"'; + //natural search + $scrit = explode(' ', $snom); + foreach ($scrit as $crit) { + $sql .= ' AND p.label LIKE "%' . $db->escape($crit) . '%"'; + } } $sql .= ' AND p.tobuy = 1'; diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index ed76755cfc0..c7be26c4861 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -103,10 +103,17 @@ if (!$user->rights->societe->client->voir && !$socid) { $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = ' . $user->id; } if ($sref) { - $sql .= ' AND cf.ref LIKE "%' . $db->escape($sref) . '%"'; + //natural search + $scrit = explode(' ', $sref); + foreach ($scrit as $crit) { + $sql .= ' AND cf.ref LIKE "%' . $db->escape($crit) . '%"'; + } } if ($snom) { - $sql .= ' AND s.nom LIKE "%' . $db->escape($snom) . '%"'; + $scrit = explode(' ', $snom); + foreach ($scrit as $crit) { + $sql .= ' AND s.nom LIKE "%' . $db->escape($crit) . '%"'; + } } if ($suser) { $sql .= ' AND u.login LIKE "%' . $db->escape($suser) . '%"';