forked from Wavyzz/dolibarr
Merge pull request #8549 from atm-greg/fix_multiselect_filter
FIX #8480
This commit is contained in:
@@ -7145,6 +7145,28 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
|||||||
$i2++; // a criteria was added to string
|
$i2++; // a criteria was added to string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($mode == 4)
|
||||||
|
{
|
||||||
|
$tmparray=explode(',',trim($crit));
|
||||||
|
|
||||||
|
if (count($tmparray))
|
||||||
|
{
|
||||||
|
$listofcodes='';
|
||||||
|
|
||||||
|
foreach($tmparray as $val)
|
||||||
|
{
|
||||||
|
if ($val)
|
||||||
|
{
|
||||||
|
$newres .= ($i2 > 0 ? ' OR (' : '(') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\'';
|
||||||
|
$newres .= ' OR '. $field . ' = \'' . $db->escape(trim($val)) . '\'';
|
||||||
|
$newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . '\'';
|
||||||
|
$newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . ',%\'';
|
||||||
|
$newres .= ')';
|
||||||
|
$i2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else // $mode=0
|
else // $mode=0
|
||||||
{
|
{
|
||||||
$textcrit = '';
|
$textcrit = '';
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ foreach ($search_array_options as $key => $val)
|
|||||||
$typ=$extrafields->attribute_type[$tmpkey];
|
$typ=$extrafields->attribute_type[$tmpkey];
|
||||||
$mode_search=0;
|
$mode_search=0;
|
||||||
if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric
|
if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric
|
||||||
if (in_array($typ, array('sellist','link','chkbxlst','checkbox')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int
|
if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int
|
||||||
|
if (in_array($typ, array('chkbxlst','checkbox'))) $mode_search=4; // Search on a multiselect field with sql type = text
|
||||||
if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1'))
|
if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1'))
|
||||||
{
|
{
|
||||||
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search);
|
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search);
|
||||||
|
|||||||
Reference in New Issue
Block a user