2
0
forked from Wavyzz/dolibarr

NEW Add option multiselect for developers on the selector of language.

This commit is contained in:
Laurent Destailleur
2019-08-28 16:06:19 +02:00
parent b05b3e897f
commit 76e8384f09
2 changed files with 10 additions and 7 deletions

View File

@@ -57,9 +57,10 @@ class FormAdmin
* @param string $morecss Add more css styles * @param string $morecss Add more css styles
* @param int $showcode 1=Add language code into label at begining, 2=Add language code into label at end * @param int $showcode 1=Add language code into label at begining, 2=Add language code into label at end
* @param int $forcecombo Force to use combo box (so no ajax beautify effect) * @param int $forcecombo Force to use combo box (so no ajax beautify effect)
* @param int $multiselect Make the combo a multiselect
* @return string Return HTML select string with list of languages * @return string Return HTML select string with list of languages
*/ */
public function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0) public function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0, $multiselect = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
@@ -70,8 +71,8 @@ class FormAdmin
$out=''; $out='';
$out.= '<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled':'').'>'; $out.= '<select '.($multiselect ? 'multiple="multiple" ' : '').'class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.($multiselect?'[]':'').'"'.($disabled?' disabled':'').'>';
if ($showempty) if ($showempty && ! $multiselect)
{ {
$out.= '<option value="0"'; $out.= '<option value="0"';
if ($selected == '') $out.= ' selected'; if ($selected == '') $out.= ' selected';

View File

@@ -7557,12 +7557,13 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
$i2++; // a criteria was added to string $i2++; // a criteria was added to string
} }
} }
elseif ($mode == 2) elseif ($mode == 2 || $mode == -2)
{ {
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $db->escape(trim($crit)) . ")"; $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " ".($mode == -2 ? 'NOT ' : '')."IN (" . $db->escape(trim($crit)) . ")";
if ($mode == -2) $newres .= ' OR '.$field.' IS NULL';
$i2++; // a criteria was added to string $i2++; // a criteria was added to string
} }
elseif ($mode == 3) elseif ($mode == 3 || $mode == -3)
{ {
$tmparray=explode(',', trim($crit)); $tmparray=explode(',', trim($crit));
if (count($tmparray)) if (count($tmparray))
@@ -7576,9 +7577,10 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
$listofcodes.="'".$db->escape(trim($val))."'"; $listofcodes.="'".$db->escape(trim($val))."'";
} }
} }
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $listofcodes . ")"; $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " ".($mode == -3 ? 'NOT ' : '')."IN (" . $listofcodes . ")";
$i2++; // a criteria was added to string $i2++; // a criteria was added to string
} }
if ($mode == -3) $newres .= ' OR '.$field.' IS NULL';
} }
elseif ($mode == 4) elseif ($mode == 4)
{ {