Skip to content
Snippets Groups Projects
Commit 54437703 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge pull request #2177 from frederic34/patch-7

Enhance select_salesrepresentatives with select2
parents 8d4186f4 d03cc03c
No related branches found
No related tags found
No related merge requests found
......@@ -356,9 +356,18 @@ class FormOther
global $conf,$langs;
$langs->load('users');
$out = '';
$nodatarole = '';
// Enhance with select2
if ($conf->use_javascript_ajax)
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out.= ajax_combobox($htmlname);
$nodatarole=' data-role="none"';
}
// Select each sales and print them in a select input
$moreforfilter ='<select class="flat" name="'.$htmlname.'">';
$moreforfilter.='<option value="">&nbsp;</option>';
$out.='<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>';
$out.='<option value="">&nbsp;</option>';
// Get list of users allowed to be viewed
$sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut, u.login";
......@@ -383,34 +392,35 @@ class FormOther
{
while ($obj_usr = $this->db->fetch_object($resql_usr))
{
$moreforfilter.='<option value="'.$obj_usr->rowid.'"';
if ($obj_usr->rowid == $selected) $moreforfilter.=' selected="selected"';
$out.='<option value="'.$obj_usr->rowid.'"';
if ($obj_usr->rowid == $selected) $out.=' selected="selected"';
$moreforfilter.='>';
$moreforfilter.=dolGetFirstLastname($obj_usr->firstname,$obj_usr->lastname);
$out.='>';
$out.=dolGetFirstLastname($obj_usr->firstname,$obj_usr->lastname);
// Complete name with more info
$moreinfo=0;
if (! empty($conf->global->MAIN_SHOW_LOGIN))
{
$moreforfilter.=($moreinfo?' - ':' (').$obj_usr->login;
$moreinfo++;
$out.=($moreinfo?' - ':' (').$obj_usr->login;
$moreinfo++;
}
if ($showstatus >= 0)
{
if ($obj_usr->statut == 1 && $showstatus == 1)
{
$moreforfilter.=($moreinfo?' - ':' (').$langs->trans('Enabled');
$out.=($moreinfo?' - ':' (').$langs->trans('Enabled');
$moreinfo++;
}
if ($obj_usr->statut == 0)
{
$moreforfilter.=($moreinfo?' - ':' (').$langs->trans('Disabled');
$out.=($moreinfo?' - ':' (').$langs->trans('Disabled');
$moreinfo++;
}
}
$moreforfilter.=($moreinfo?')':'');
$moreforfilter.='</option>';
$out.=($moreinfo?')':'');
$out.='</option>';
}
$this->db->free($resql_usr);
}
......@@ -418,9 +428,9 @@ class FormOther
{
dol_print_error($this->db);
}
$moreforfilter.='</select>';
$out.='</select>';
return $moreforfilter;
return $out;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment