select_dolusers can return rich array of users
This commit is contained in:
parent
68ede86353
commit
9ccc806f3a
@ -1961,7 +1961,7 @@ class Form
|
|||||||
* @param array $exclude Array list of users id to exclude
|
* @param array $exclude Array list of users id to exclude
|
||||||
* @param int $disabled If select list must be disabled
|
* @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 $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 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 string $force_entity '0' or Ids of environment to force
|
||||||
* @param int $maxlength Maximum length of string into list (0=no limit)
|
* @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 int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
|
||||||
@ -2013,6 +2013,7 @@ class Form
|
|||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
$outarray = array();
|
$outarray = array();
|
||||||
|
$outarray2 = array();
|
||||||
|
|
||||||
// Forge request to select users
|
// 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";
|
$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 ? ')' : '');
|
$moreinfo .= ($moreinfo ? ')' : '');
|
||||||
$moreinfohtml .= ($moreinfohtml ? ')' : '');
|
$moreinfohtml .= ($moreinfohtml ? ')</span>' : '');
|
||||||
if ($disableline && $disableline != '1') {
|
if ($disableline && $disableline != '1') {
|
||||||
// Add text from $enableonlytext parameter
|
// Add text from $enableonlytext parameter
|
||||||
$moreinfo .= ' - ' . $disableline;
|
$moreinfo .= ' - ' . $disableline;
|
||||||
@ -2182,6 +2183,11 @@ class Form
|
|||||||
$out .= '</option>';
|
$out .= '</option>';
|
||||||
|
|
||||||
$outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength) . $moreinfo;
|
$outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength) . $moreinfo;
|
||||||
|
$outarray2[$userstatic->id] = array(
|
||||||
|
'id'=>$userstatic->id,
|
||||||
|
'label'=>$labeltoshow,
|
||||||
|
'labelhtml'=>$labeltoshowhtml
|
||||||
|
);
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -2200,7 +2206,9 @@ class Form
|
|||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($outputmode) {
|
if ($outputmode == 2) {
|
||||||
|
return $outarray2;
|
||||||
|
} elseif ($outputmode) {
|
||||||
return $outarray;
|
return $outarray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8462,7 +8470,7 @@ class Form
|
|||||||
* Show a multiselect form from an array. WARNING: Use this only for short lists.
|
* Show a multiselect form from an array. WARNING: Use this only for short lists.
|
||||||
*
|
*
|
||||||
* @param string $htmlname Name of select
|
* @param string $htmlname Name of select
|
||||||
* @param array $array Array(key=>value) or Array(key=>array('id'=> , 'label'=> ))
|
* @param array $array Array(key=>value) or Array(key=>array('id'=> , 'label'=> , 'color'=> , 'picto'=> , 'labelhtml'=> ))
|
||||||
* @param array $selected Array of keys preselected
|
* @param array $selected Array of keys preselected
|
||||||
* @param int $key_in_label 1 to show key like in "[key] value"
|
* @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 int $value_as_key 1 to use value as key
|
||||||
@ -8508,11 +8516,13 @@ class Form
|
|||||||
$tmpvalue = $value;
|
$tmpvalue = $value;
|
||||||
$tmpcolor = '';
|
$tmpcolor = '';
|
||||||
$tmppicto = '';
|
$tmppicto = '';
|
||||||
|
$tmplabelhtml = '';
|
||||||
if (is_array($value) && array_key_exists('id', $value) && array_key_exists('label', $value)) {
|
if (is_array($value) && array_key_exists('id', $value) && array_key_exists('label', $value)) {
|
||||||
$tmpkey = $value['id'];
|
$tmpkey = $value['id'];
|
||||||
$tmpvalue = $value['label'];
|
$tmpvalue = $value['label'];
|
||||||
$tmpcolor = $value['color'];
|
$tmpcolor = $value['color'];
|
||||||
$tmppicto = $value['picto'];
|
$tmppicto = $value['picto'];
|
||||||
|
$tmplabelhtml = $value['labelhtml'];
|
||||||
}
|
}
|
||||||
$newval = ($translate ? $langs->trans($tmpvalue) : $tmpvalue);
|
$newval = ($translate ? $langs->trans($tmpvalue) : $tmpvalue);
|
||||||
$newval = ($key_in_label ? $tmpkey . ' - ' . $newval : $newval);
|
$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 != '')) {
|
if (is_array($selected) && !empty($selected) && in_array((string) $tmpkey, $selected) && ((string) $tmpkey != '')) {
|
||||||
$out .= ' selected';
|
$out .= ' selected';
|
||||||
}
|
}
|
||||||
|
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 .= ' data-html="' . dol_escape_htmltag(($tmppicto ? img_picto('', $tmppicto, 'class="pictofixedwidth" style="color: #' . $tmpcolor . '"') : '') . $newval) . '"';
|
||||||
|
}
|
||||||
$out .= '>';
|
$out .= '>';
|
||||||
$out .= dol_htmlentitiesbr($newval);
|
$out .= dol_htmlentitiesbr($newval);
|
||||||
$out .= '</option>' . "\n";
|
$out .= '</option>' . "\n";
|
||||||
|
|||||||
@ -1863,7 +1863,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).'</td>';
|
print '<td>'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).'</td>';
|
||||||
print '<td colspan="3" class="maxwidthonsmartphone">';
|
print '<td colspan="3" class="maxwidthonsmartphone">';
|
||||||
$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1);
|
$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'AND u.statut = 1', 0, '', '', 0, 2);
|
||||||
// Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record.
|
// Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record.
|
||||||
$selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (empty($user->rights->societe->client->voir) ? array($user->id) : array())));
|
$selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (empty($user->rights->societe->client->voir) ? array($user->id) : array())));
|
||||||
print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
|
print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user