forked from Wavyzz/dolibarr
Merge branch '5.0' of git@github.com:Dolibarr/dolibarr.git into 6.0
Conflicts: htdocs/commande/card.php htdocs/core/lib/functions.lib.php htdocs/fourn/card.php htdocs/public/members/new.php
This commit is contained in:
@@ -6261,29 +6261,39 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
||||
$i3 = 0;
|
||||
foreach($tmpcrits as $tmpcrit)
|
||||
{
|
||||
$newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '') . $field . " LIKE '";
|
||||
$newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
|
||||
|
||||
if (preg_match('/\.(id|rowid)$/', $field)) // Special cas for rowid that is sometimes a ref so used as a search field
|
||||
{
|
||||
$newres .= $field . " = " . (is_numeric(trim($tmpcrit))?trim($tmpcrit):'0');
|
||||
}
|
||||
else
|
||||
{
|
||||
$newres .= $field . " LIKE '";
|
||||
|
||||
$tmpcrit=trim($tmpcrit);
|
||||
$tmpcrit2=$tmpcrit;
|
||||
$tmpbefore='%'; $tmpafter='%';
|
||||
if (preg_match('/^[\^\$]/', $tmpcrit))
|
||||
{
|
||||
$tmpbefore='';
|
||||
$tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
|
||||
}
|
||||
if (preg_match('/[\^\$]$/', $tmpcrit))
|
||||
{
|
||||
$tmpafter='';
|
||||
$tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
|
||||
}
|
||||
$newres .= $tmpbefore;
|
||||
$newres .= $db->escape($tmpcrit2);
|
||||
$newres .= $tmpafter;
|
||||
$newres .= "'";
|
||||
if ($tmpcrit2 == '')
|
||||
{
|
||||
$newres .= ' OR ' . $field . " IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
$tmpcrit=trim($tmpcrit);
|
||||
$tmpcrit2=$tmpcrit;
|
||||
$tmpbefore='%'; $tmpafter='%';
|
||||
if (preg_match('/^[\^\$]/', $tmpcrit))
|
||||
{
|
||||
$tmpbefore='';
|
||||
$tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
|
||||
}
|
||||
if (preg_match('/[\^\$]$/', $tmpcrit))
|
||||
{
|
||||
$tmpafter='';
|
||||
$tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
|
||||
}
|
||||
$newres .= $tmpbefore;
|
||||
$newres .= $db->escape($tmpcrit2);
|
||||
$newres .= $tmpafter;
|
||||
$newres .= "'";
|
||||
if ($tmpcrit2 == '')
|
||||
{
|
||||
$newres .= ' OR ' . $field . " IS NULL";
|
||||
}
|
||||
$i3++;
|
||||
}
|
||||
$i2++; // a criteria was added to string
|
||||
|
||||
Reference in New Issue
Block a user