diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d176d0c56a4..1c453d49a8a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1955,25 +1955,25 @@ class Form /** * Return select list of users * - * @param string $selected User id or user object of user preselected. If 0 or < -2, we use id of current user. If -1, keep unselected (if empty is allowed) - * @param string $htmlname Field name in form - * @param int|string $show_empty 0=list with no empty value, 1=add also an empty value into list - * @param array $exclude Array list of users id to exclude - * @param int $disabled If select list must be disabled - * @param array|string $include Array list of users id to include. User '' for all users or 'hierarchy' to have only supervised users or 'hierarchyme' to have supervised + me - * @param array $enableonly Array list of users id to be enabled. If defined, it means that others will be disabled - * @param string $force_entity '0' or Ids of environment to force - * @param int $maxlength Maximum length of string into list (0=no limit) - * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status - * @param string $morefilter Add more filters into sql request (Example: 'employee = 1'). This value must not come from user input. - * @param integer $show_every 0=default list, 1=add also a value "Everybody" at beginning of list - * @param string $enableonlytext If option $enableonlytext is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. - * @param string $morecss More css - * @param int $notdisabled Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on). - * @param int $outputmode 0=HTML select string, 1=Array - * @param bool $multiple add [] in the name of element and add 'multiple' attribut - * @param int $forcecombo Force the component to be a simple combo box without ajax - * @return array|string HTML select string + * @param string $selected User id or user object of user preselected. If 0 or < -2, we use id of current user. If -1, keep unselected (if empty is allowed) + * @param string $htmlname Field name in form + * @param int|string $show_empty 0=list with no empty value, 1=add also an empty value into list + * @param array $exclude Array list of users id to exclude + * @param int $disabled If select list must be disabled + * @param array|string $include Array list of users id to include. User '' for all users or 'hierarchy' to have only supervised users or 'hierarchyme' to have supervised + me + * @param array|string $enableonly Array list of users id to be enabled. If defined, it means that others will be disabled + * @param string $force_entity '0' or Ids of environment to force + * @param int $maxlength Maximum length of string into list (0=no limit) + * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status + * @param string $morefilter Add more filters into sql request (Example: 'employee = 1'). This value must not come from user input. + * @param integer $show_every 0=default list, 1=add also a value "Everybody" at beginning of list + * @param string $enableonlytext If option $enableonlytext is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. + * @param string $morecss More css + * @param int $notdisabled Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on). + * @param int $outputmode 0=HTML select string, 1=Array + * @param bool $multiple add [] in the name of element and add 'multiple' attribut + * @param int $forcecombo Force the component to be a simple combo box without ajax + * @return array|string HTML select string * @see select_dolgroups() */ public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $notdisabled = 0, $outputmode = 0, $multiple = false, $forcecombo = 0) @@ -2013,6 +2013,7 @@ class Form $out = ''; $outarray = array(); + $outarray2 = array(); // Forge request to select users $sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.photo"; @@ -2151,7 +2152,7 @@ class Form } } $moreinfo .= ($moreinfo ? ')' : ''); - $moreinfohtml .= ($moreinfohtml ? ')' : ''); + $moreinfohtml .= ($moreinfohtml ? ')' : ''); if ($disableline && $disableline != '1') { // Add text from $enableonlytext parameter $moreinfo .= ' - ' . $disableline; @@ -2182,6 +2183,11 @@ class Form $out .= ''; $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength) . $moreinfo; + $outarray2[$userstatic->id] = array( + 'id'=>$userstatic->id, + 'label'=>$labeltoshow, + 'labelhtml'=>$labeltoshowhtml + ); $i++; } @@ -2200,7 +2206,9 @@ class Form dol_print_error($this->db); } - if ($outputmode) { + if ($outputmode == 2) { + return $outarray2; + } elseif ($outputmode) { return $outarray; } @@ -8461,19 +8469,19 @@ class Form /** * Show a multiselect form from an array. WARNING: Use this only for short lists. * - * @param string $htmlname Name of select - * @param array $array Array(key=>value) or Array(key=>array('id'=> , 'label'=> )) - * @param array $selected Array of keys preselected - * @param int $key_in_label 1 to show key like in "[key] value" - * @param int $value_as_key 1 to use value as key - * @param string $morecss Add more css style - * @param int $translate Translate and encode value - * @param int|string $width Force width of select box. May be used only when using jquery couch. Example: 250, '95%' - * @param string $moreattrib Add more options on select component. Example: 'disabled' - * @param string $elemtype Type of element we show ('category', ...). Will execute a formating function on it. To use in readonly mode if js component support HTML formatting. - * @param string $placeholder String to use as placeholder - * @param int $addjscombo Add js combo - * @return string HTML multiselect string + * @param string $htmlname Name of select + * @param array $array Array(key=>value) or Array(key=>array('id'=> , 'label'=> , 'color'=> , 'picto'=> , 'labelhtml'=> )) + * @param array $selected Array of keys preselected + * @param int $key_in_label 1 to show key like in "[key] value" + * @param int $value_as_key 1 to use value as key + * @param string $morecss Add more css style + * @param int $translate Translate and encode value + * @param int|string $width Force width of select box. May be used only when using jquery couch. Example: 250, '95%' + * @param string $moreattrib Add more options on select component. Example: 'disabled' + * @param string $elemtype Type of element we show ('category', ...). Will execute a formating function on it. To use in readonly mode if js component support HTML formatting. + * @param string $placeholder String to use as placeholder + * @param int $addjscombo Add js combo + * @return string HTML multiselect string * @see selectarray(), selectArrayAjax(), selectArrayFilter() */ public static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss = '', $translate = 0, $width = 0, $moreattrib = '', $elemtype = '', $placeholder = '', $addjscombo = -1) @@ -8508,11 +8516,13 @@ class Form $tmpvalue = $value; $tmpcolor = ''; $tmppicto = ''; + $tmplabelhtml = ''; if (is_array($value) && array_key_exists('id', $value) && array_key_exists('label', $value)) { $tmpkey = $value['id']; $tmpvalue = $value['label']; $tmpcolor = $value['color']; $tmppicto = $value['picto']; + $tmplabelhtml = $value['labelhtml']; } $newval = ($translate ? $langs->trans($tmpvalue) : $tmpvalue); $newval = ($key_in_label ? $tmpkey . ' - ' . $newval : $newval); @@ -8521,7 +8531,11 @@ class Form if (is_array($selected) && !empty($selected) && in_array((string) $tmpkey, $selected) && ((string) $tmpkey != '')) { $out .= ' selected'; } - $out .= ' data-html="' . dol_escape_htmltag(($tmppicto ? img_picto('', $tmppicto, 'class="pictofixedwidth" style="color: #' . $tmpcolor . '"') : '') . $newval) . '"'; + if (!empty($tmplabelhtml)) { + $out .= ' data-html="' . dol_escape_htmltag($tmplabelhtml) . '"'; + } else { + $out .= ' data-html="' . dol_escape_htmltag(($tmppicto ? img_picto('', $tmppicto, 'class="pictofixedwidth" style="color: #' . $tmpcolor . '"') : '') . $newval) . '"'; + } $out .= '>'; $out .= dol_htmlentitiesbr($newval); $out .= '' . "\n"; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 1649a161034..d298c34719d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1632,7 +1632,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '