diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 784c8bc926f..941865da45a 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -13,6 +13,7 @@
* Copyright (C) 2010 Philippe Grand
* Copyright (C) 2011 Herve Prot
* Copyright (C) 2012 Marcos García
+ * Copyright (C) 2013 Raphaël Doursenaud
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1223,9 +1224,13 @@ class Form
}
else
{
- $sql.=" AND (p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%'";
- if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '%".$filterkey."%'";
- $sql.=")";
+ // For natural search
+ $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))