Fix search degradation
This commit is contained in:
parent
8e4c7efed5
commit
5e644ed0a4
@ -139,7 +139,6 @@ $search_btn = GETPOST('button_search', 'alpha');
|
|||||||
$search_remove_btn = GETPOST('button_removefilter', 'alpha');
|
$search_remove_btn = GETPOST('button_removefilter', 'alpha');
|
||||||
$optioncss = GETPOST('optioncss', 'alpha');
|
$optioncss = GETPOST('optioncss', 'alpha');
|
||||||
|
|
||||||
|
|
||||||
$option = GETPOST('search_option');
|
$option = GETPOST('search_option');
|
||||||
if ($option == 'late') {
|
if ($option == 'late') {
|
||||||
$search_status = '1';
|
$search_status = '1';
|
||||||
|
|||||||
@ -1173,35 +1173,56 @@ class ExtraFields
|
|||||||
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'> ';
|
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'> ';
|
||||||
} elseif ($type == 'select') {
|
} elseif ($type == 'select') {
|
||||||
$out = '';
|
$out = '';
|
||||||
if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
|
if ($mode) {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
$options = array();
|
||||||
$out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
|
foreach ($param['options'] as $okey => $val) {
|
||||||
}
|
if ((string) $okey == '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>';
|
if ($langfile && $val) {
|
||||||
$out .= '<option value="0"> </option>';
|
$options[$okey] = $langs->trans($val);
|
||||||
foreach ($param['options'] as $key => $val) {
|
} else {
|
||||||
if ((string) $key == '') {
|
$options[$okey] = $val;
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
$valarray = explode('|', $val);
|
$selected = array();
|
||||||
$val = $valarray[0];
|
if (!is_array($value)) {
|
||||||
$parent = '';
|
$selected = explode(',', $value);
|
||||||
if (!empty($valarray[1])) {
|
|
||||||
$parent = $valarray[1];
|
|
||||||
}
|
}
|
||||||
$out .= '<option value="'.$key.'"';
|
|
||||||
$out .= (((string) $value == (string) $key) ? ' selected' : '');
|
$out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0, '', '', '', !empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2));
|
||||||
$out .= (!empty($parent) ? ' parent="'.$parent.'"' : '');
|
} else {
|
||||||
$out .= '>';
|
if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
|
||||||
if ($langfile && $val) {
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||||
$out .= $langs->trans($val);
|
$out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
|
||||||
} else {
|
|
||||||
$out .= $val;
|
|
||||||
}
|
}
|
||||||
$out .= '</option>';
|
|
||||||
|
$out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>';
|
||||||
|
$out .= '<option value="0"> </option>';
|
||||||
|
foreach ($param['options'] as $key => $val) {
|
||||||
|
if ((string) $key == '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$valarray = explode('|', $val);
|
||||||
|
$val = $valarray[0];
|
||||||
|
$parent = '';
|
||||||
|
if (!empty($valarray[1])) {
|
||||||
|
$parent = $valarray[1];
|
||||||
|
}
|
||||||
|
$out .= '<option value="'.$key.'"';
|
||||||
|
$out .= (((string) $value == (string) $key) ? ' selected' : '');
|
||||||
|
$out .= (!empty($parent) ? ' parent="'.$parent.'"' : '');
|
||||||
|
$out .= '>';
|
||||||
|
if ($langfile && $val) {
|
||||||
|
$out .= $langs->trans($val);
|
||||||
|
} else {
|
||||||
|
$out .= $val;
|
||||||
|
}
|
||||||
|
$out .= '</option>';
|
||||||
|
}
|
||||||
|
$out .= '</select>';
|
||||||
}
|
}
|
||||||
$out .= '</select>';
|
|
||||||
} elseif ($type == 'sellist') {
|
} elseif ($type == 'sellist') {
|
||||||
$out = '';
|
$out = '';
|
||||||
if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
|
if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
|
||||||
@ -2208,6 +2229,17 @@ class ExtraFields
|
|||||||
} else {
|
} else {
|
||||||
continue; // Value was not provided, we should not set it.
|
continue; // Value was not provided, we should not set it.
|
||||||
}
|
}
|
||||||
|
} elseif ($key_type == 'select') {
|
||||||
|
// to detect if we are in search context
|
||||||
|
$value_arr_test = GETPOST($keysuffix."options_".$key.$keyprefix, 'none');
|
||||||
|
if (is_array($value_arr_test)) {
|
||||||
|
$value_arr = GETPOST($keysuffix."options_".$key.$keyprefix, 'array:aZ09');
|
||||||
|
// Make sure we get an array even if there's only one selected
|
||||||
|
$value_arr = (array) $value_arr;
|
||||||
|
$value_key = implode(',', $value_arr);
|
||||||
|
} else {
|
||||||
|
$value_key = GETPOST($keysuffix."options_".$key.$keyprefix);
|
||||||
|
}
|
||||||
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) {
|
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) {
|
||||||
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) {
|
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) {
|
||||||
continue; // Value was not provided, we should not set it.
|
continue; // Value was not provided, we should not set it.
|
||||||
|
|||||||
@ -48,7 +48,7 @@ if (!empty($extrafieldsobjectkey) && !empty($search_array_options) && is_array($
|
|||||||
}
|
}
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
}
|
}
|
||||||
} elseif ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) {
|
} elseif ($crit != '' && (!in_array($typ, array('select', 'sellist', 'select')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) {
|
||||||
$mode_search = 0;
|
$mode_search = 0;
|
||||||
if (in_array($typ, array('int', 'double', 'real', 'price'))) {
|
if (in_array($typ, array('int', 'double', 'real', 'price'))) {
|
||||||
$mode_search = 1; // Search on a numeric
|
$mode_search = 1; // Search on a numeric
|
||||||
@ -59,13 +59,14 @@ if (!empty($extrafieldsobjectkey) && !empty($search_array_options) && is_array($
|
|||||||
if (in_array($typ, array('sellist')) && !is_numeric($crit)) {
|
if (in_array($typ, array('sellist')) && !is_numeric($crit)) {
|
||||||
$mode_search = 0;// Search on a foreign key string
|
$mode_search = 0;// Search on a foreign key string
|
||||||
}
|
}
|
||||||
if (in_array($typ, array('chkbxlst', 'checkbox'))) {
|
if (in_array($typ, array('chkbxlst', 'checkbox', 'select'))) {
|
||||||
$mode_search = 4; // Search on a multiselect field with sql type = text
|
$mode_search = 4; // Search on a multiselect field with sql type = text
|
||||||
}
|
}
|
||||||
if (is_array($crit)) {
|
if (is_array($crit)) {
|
||||||
$crit = implode(' ', $crit); // natural_search() expects a string
|
$crit = implode(' ', $crit); // natural_search() expects a string
|
||||||
} elseif ($typ === 'select' and is_string($crit) and strpos($crit, ' ') === false) {
|
} elseif ($typ === 'select' and is_string($crit) and strpos($crit, ',') === false) {
|
||||||
$sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." = '".$db->escape($crit)."')";
|
$critSelect = implode("','", array_map(array($db, 'escape'), explode(',', $crit)));
|
||||||
|
$sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." IN ('".$critSelect."') )";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$sql .= natural_search($extrafieldsobjectprefix.$tmpkey, $crit, $mode_search);
|
$sql .= natural_search($extrafieldsobjectprefix.$tmpkey, $crit, $mode_search);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user