forked from Dolibarr/dolibarr
/
index.php
153 lines (133 loc) · 5.46 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/user/index.php
* \ingroup core
* \brief Page of users
* \version $Id: index.php,v 1.51 2011/07/31 23:19:42 eldy Exp $
*/
require("../main.inc.php");
if (! $user->rights->user->user->lire && ! $user->admin) accessforbidden();
$langs->load("users");
$langs->load("companies");
// Security check (for external users)
$socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id;
$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"];
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$limit = $conf->liste_limit;
if (! $sortfield) $sortfield="u.login";
if (! $sortorder) $sortorder="ASC";
$userstatic=new User($db);
$companystatic = new Societe($db);
/*
* View
*/
llxHeader();
print_fiche_titre($langs->trans("ListOfUsers"));
$sql = "SELECT u.rowid, u.name, u.firstname, u.admin, u.fk_societe, u.login,";
$sql.= " u.datec,";
$sql.= " u.tms as datem,";
$sql.= " u.datelastlogin,";
$sql.= " u.ldap_sid, u.statut, u.entity,";
$sql.= " s.nom, s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_societe = s.rowid";
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
if (!empty($socid)) $sql.= " AND u.fk_societe = ".$socid;
if ($_POST["search_user"])
{
$sql.= " AND (u.login like '%".$_POST["search_user"]."%' OR u.name like '%".$_POST["search_user"]."%' OR u.firstname like '%".$_POST["search_user"]."%')";
}
if ($sall) $sql.= " AND (u.login like '%".$sall."%' OR u.name like '%".$sall."%' OR u.firstname like '%".$sall."%' OR u.email like '%".$sall."%' OR u.note like '%".$sall."%')";
if ($sortfield) $sql.=" ORDER BY $sortfield $sortorder";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$param="search_user=$search_user&sall=$sall";
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Login"),"index.php","u.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LastName"),"index.php","u.name",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("FirstName"),"index.php","u.firstname",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),"index.php","u.fk_societe",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateCreation"),"index.php","u.datec",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LastConnexion"),"index.php","u.datelastlogin",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"index.php","u.status",$param,"",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'</a>';
if ($conf->global->MAIN_MODULE_MULTICOMPANY && $obj->admin && ! $obj->entity)
{
print img_redstar($langs->trans("SuperAdministrator"));
}
else if ($obj->admin)
{
print img_picto($langs->trans("Administrator"),'star');
}
print '</td>';
print '<td>'.ucfirst($obj->name).'</td>';
print '<td>'.ucfirst($obj->firstname).'</td>';
print "<td>";
if ($obj->fk_societe)
{
$companystatic->id=$obj->fk_societe;
$companystatic->nom=$obj->nom;
$companystatic->canvas=$obj->canvas;
print $companystatic->getNomUrl(1);
}
else if ($obj->ldap_sid)
{
print $langs->trans("DomainUser");
}
else print $langs->trans("InternalUser");
print '</td>';
// Date creation
print '<td nowrap="nowrap" align="center">'.dol_print_date($db->jdate($obj->datec),"dayhour").'</td>';
// Date last login
print '<td nowrap="nowrap" align="center">'.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").'</td>';
// Statut
$userstatic->statut=$obj->statut;
print '<td width="100" align="right">'.$userstatic->getLibStatut(5).'</td>';
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($result);
}
else
{
dol_print_error($db);
}
$db->close();
llxFooter('$Date: 2011/07/31 23:19:42 $ - $Revision: 1.51 $');
?>