30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
34$langs->loadLangs(array(
'users',
'companies',
'hrm',
'salaries'));
38if ($user->socid > 0) {
39 $socid = $user->socid;
42$optioncss =
GETPOST(
'optioncss',
'alpha');
43$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'userlist';
44$mode =
GETPOST(
"mode",
'alpha');
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
54$search_status =
GETPOST(
'search_statut',
'int') ?
GETPOST(
'search_statut',
'int') :
GETPOST(
'search_status',
'int');
55if ($search_status ===
'') {
59if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
64if ($contextpage ==
'employeelist') {
68$userstatic =
new User($db);
71$canadduser = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write"));
74if (isModEnabled(
'salaries') && $contextpage ==
'employeelist' && $search_employee == 1) {
75 if (!$user->hasRight(
"salaries",
"read")) {
79 if (!$user->hasRight(
"user",
"user",
"read") && empty($user->admin)) {
84$childids = $user->getAllChildIds(1);
94$help_url =
'EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios|DE:Modul_Benutzer';
95if ($contextpage ==
'employeelist' && $search_employee == 1) {
96 $title = $langs->trans(
"Employees");
98 $title = $langs->trans(
"Users");
101 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
102 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js',
104$arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
106llxHeader(
'', $title, $help_url,
'', 0, 0, $arrayofjs, $arrayofcss,
'',
'bodyforlist');
109if (($search_status !=
'' && $search_status >= 0)) {
110 $filters[] =
"statut = ".((int) $search_status);
112if (($search_employee !=
'' && $search_employee >= 0)) {
113 $filters[] =
"employee = ".((int) $search_employee);
116if (!empty($filters)) {
117 $sqlfilter = join(
' AND ', $filters);
120$user_arbo_all = $userstatic->get_full_tree(0,
'');
122 $user_arbo = $userstatic->get_full_tree(0, $sqlfilter);
124 $user_arbo = $user_arbo_all;
128$nbtotalofrecords = count($user_arbo);
131if (!is_array($user_arbo) && $user_arbo < 0) {
135 $fulltree = $user_arbo;
139 $data[0] = array(
'rowid'=>0,
'fk_menu'=>-1,
'title'=>
"racine",
'mainmenu'=>
'',
'leftmenu'=>
'',
'fk_mainmenu'=>
'',
'fk_leftmenu'=>
'');
141 foreach ($fulltree as $key => $val) {
142 $userstatic->id = $val[
'id'];
143 $userstatic->ref = $val[
'id'];
144 $userstatic->login = $val[
'login'];
145 $userstatic->firstname = $val[
'firstname'];
146 $userstatic->lastname = $val[
'lastname'];
147 $userstatic->statut = $val[
'statut'];
148 $userstatic->email = $val[
'email'];
149 $userstatic->gender = $val[
'gender'];
150 $userstatic->socid = $val[
'fk_soc'];
151 $userstatic->admin = $val[
'admin'];
152 $userstatic->entity = $val[
'entity'];
153 $userstatic->photo = $val[
'photo'];
155 $entity = $val[
'entity'];
159 if (isModEnabled(
'multicompany') && is_object($mc)) {
160 if (empty($entity)) {
161 $entitystring = $langs->trans(
"AllEntities");
163 $mc->getInfo($entity);
164 $entitystring = $mc->label;
168 $li = $userstatic->getNomUrl(-1,
'', 0, 1);
169 if (isModEnabled(
'multicompany') && $userstatic->admin && !$userstatic->entity) {
170 $li .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
'redstar',
'class="valignmiddle paddingright paddingleft"');
171 } elseif ($userstatic->admin) {
172 $li .=
img_picto($langs->trans(
"AdministratorDesc"),
'star',
'class="valignmiddle paddingright paddingleft"');
174 $li .=
' <span class="opacitymedium">('.$val[
'login'].($entitystring ?
' - '.$entitystring :
'').
')</span>';
176 $entry =
'<table class="nobordernopadding centpercent"><tr class="trtree"><td class="'.($val[
'statut'] ?
'usertdenabled' :
'usertddisabled').
'">'.$li.
'</td><td align="right" class="'.($val[
'statut'] ?
'usertdenabled' :
'usertddisabled').
'">'.$userstatic->getLibStatut(2).
'</td></tr></table>';
178 $data[$val[
'rowid']] = array(
179 'rowid'=>$val[
'rowid'],
180 'fk_menu'=>$val[
'fk_user'],
181 'statut'=>$val[
'statut'],
187 foreach ($data as $key => $tmpdata) {
188 $idparent = $tmpdata[
'fk_menu'];
191 $parentfound = array_key_exists($idparent, $data) ? 1 : 0;
194 while (!$parentfound && $i < 50) {
196 if (!empty($user_arbo_all[$idparent])) {
197 $val = $user_arbo_all[$idparent];
198 $userstatic->id = $val[
'id'];
199 $userstatic->ref = $val[
'id'];
200 $userstatic->login = $val[
'login'];
201 $userstatic->firstname = $val[
'firstname'];
202 $userstatic->lastname = $val[
'lastname'];
203 $userstatic->statut = $val[
'statut'];
204 $userstatic->email = $val[
'email'];
205 $userstatic->gender = $val[
'gender'];
206 $userstatic->socid = $val[
'fk_soc'];
207 $userstatic->admin = $val[
'admin'];
208 $userstatic->entity = $val[
'entity'];
209 $userstatic->photo = $val[
'photo'];
211 $li =
'<span class="opacitymedium">';
212 $li .= $userstatic->getNomUrl(-1,
'', 0, 1);
213 if (isModEnabled(
'multicompany') && $userstatic->admin && !$userstatic->entity) {
214 $li .=
img_picto($langs->trans(
"SuperAdministrator"),
'redstar');
215 } elseif ($userstatic->admin) {
216 $li .=
img_picto($langs->trans(
"Administrator"),
'star');
218 $li .=
' <span class="opacitymedium">('.$val[
'login'].($entitystring ?
' - '.$entitystring :
'').
')</span>';
219 $li .=
' - <span class="opacitymedium">'.$langs->trans(
"ExcludedByFilter").
'</span>';
222 $entry =
'<table class="nobordernopadding centpercent"><tr class="trtree"><td class="'.($val[
'statut'] ?
'usertdenabled' :
'usertddisabled').
'">'.$li.
'</td><td align="right" class="'.($val[
'statut'] ?
'usertdenabled' :
'usertddisabled').
'">'.$userstatic->getLibStatut(2).
'</td></tr></table>';
224 $data[$idparent] = array(
225 'rowid' => $idparent,
226 'fk_menu' => $user_arbo_all[$idparent][
'fk_user'],
227 'statut' => $user_arbo_all[$idparent][
'statut'],
230 $idparent = $user_arbo_all[$idparent][
'fk_user'];
232 $parentfound = array_key_exists($idparent, $data) ? 1 : 0;
239 $data[$key][
'fk_menu'] = -2;
240 if (empty($data[-2])) {
241 $li =
'<span class="opacitymedium">'.$langs->trans(
"ParentIDDoesNotExistAnymore").
'</span>';
242 $entry =
'<table class="nobordernopadding centpercent"><tr class="trtree"><td class="usertddisabled">'.$li.
'</td><td align="right" class="usertddisabled"></td></tr></table>';
259 $param =
"&search_status=".urlencode($search_status);
260 $param =
"&contextpage=".urlencode($contextpage);
263 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars paddingleft imgforviewmode', DOL_URL_ROOT.
'/user/list.php?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss'=>
'reposition'));
264 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'HierarchicView'),
'',
'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.
'/user/hierarchy.php?mode=hierarchy'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', (($mode ==
'hierarchy') ? 2 : 1), array(
'morecss'=>
'reposition'));
265 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', DOL_URL_ROOT.
'/user/list.php?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss'=>
'reposition'));
267 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewUser'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/user/card.php?action=create'.($mode ==
'employee' ?
'&employee=1' :
'').
'&leftmenu=',
'', $canadduser);
269 $massactionbutton =
'';
273 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'user', 0, $newcardbutton,
'', $limit, 0, 0, 1);
275 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
276 if ($optioncss !=
'') {
277 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
279 print
'<input type="hidden" name="token" value="'.newToken().
'">';
280 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
281 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
282 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
283 print
'<input type="hidden" name="page" value="'.$page.
'">';
284 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
285 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
287 print
'<div class="div-table-responsive">';
288 print
'<table class="liste nohover centpercent">';
290 print
'<tr class="liste_titre_filter">';
293 print
'<td class="liste_titre maxwidthsearch">';
294 $searchpicto = $form->showFilterAndCheckAddButtons(0);
298 print
'<td class="liste_titre"> </td>';
299 print
'<td class="liste_titre"> </td>';
301 print
'<td class="liste_titre right parentonrightofpage">';
302 print $form->selectarray(
'search_status', array(
'-1'=>
'',
'0'=>$langs->trans(
'Disabled'),
'1'=>$langs->trans(
'Enabled')), $search_status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75imp onrightofpage width100');
306 print
'<td class="liste_titre maxwidthsearch">';
307 $searchpicto = $form->showFilterAndCheckAddButtons(0);
313 print
'<tr class="liste_titre">';
319 print_liste_field_titre(
'<div id="iddivjstreecontrol"><a href="#">'.
img_picto(
'',
'folder',
'class="paddingright"').
'<span class="hideonsmartphone">'.$langs->trans(
"UndoExpandAll").
'</span></a> | <a href="#">'.
img_picto(
'',
'folder-open',
'class="paddingright"').
'<span class="hideonsmartphone">'.$langs->trans(
"ExpandAll").
'</span></a></div>', $_SERVER[
'PHP_SELF'],
"",
'',
"",
'align="center"');
328 $nbofentries = (count($data) - 1);
330 if ($nbofentries > 0) {
336 print
'<td colspan="3">';
345 print
'<tr class="oddeven">';
346 print
'<td colspan="3">';
347 print
'<table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common(
'',
'treemenu/branchbottom.gif').
'</td>';
348 print
'<td valign="middle">';
349 print $langs->trans(
"NoCategoryYet");
351 print
'<td> </td>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage Dolibarr users.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0, $moreparam='')
Recursive function to output a tree.