25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
29 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'userhome';
31 if (!$user->rights->user->user->lire && !$user->admin) {
33 header(
"Location: card.php?id=".$user->id);
38 $langs->load(
"users");
41 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
42 $canreadperms = ($user->admin || $user->rights->user->group_advance->read);
47 if ($user->socid > 0) {
48 $socid = $user->socid;
51 $companystatic =
new Societe($db);
52 $fuserstatic =
new User($db);
55 $hookmanager->initHooks(array(
'userhome'));
64 require_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
65 $zone =
GETPOST(
'areacode',
'int');
66 $userid =
GETPOST(
'userid',
'int');
67 $boxorder =
GETPOST(
'boxorder',
'aZ09');
68 $boxorder .=
GETPOST(
'boxcombo',
'aZ09');
82 print
load_fiche_titre($langs->trans(
"MenuUsersAndGroups"), $resultboxes[
'selectboxlist'],
'user');
86 $searchbox =
'<form method="post" action="'.DOL_URL_ROOT.
'/core/search.php">';
87 $searchbox .=
'<input type="hidden" name="token" value="'.newToken().
'">';
89 $searchbox .=
'<table class="noborder nohover centpercent">';
90 $searchbox .=
'<tr class="liste_titre"><td colspan="2">'.$langs->trans(
"Search").
'</td></tr>';
91 $searchbox .=
'<tr><td>';
92 $searchbox .= $langs->trans(
"User").
':</td><td><input class="flat inputsearch width200" type="text" name="search_user"></td></tr>';
96 $searchbox .=
'<tr><td>';
97 $searchbox .= $langs->trans(
"Group").
':</td><td><input class="flat inputsearch width200" type="text" name="search_group"></td></tr>';
100 $searchbox .=
'<tr><td class="center" colspan="2"><input type="submit" value="'.$langs->trans(
"Search").
'" class="button"></td></tr>';
101 $searchbox .=
"</table><br>\n";
103 $searchbox .=
'</form>';
110 $lastcreatedbox =
'';
111 $sql =
"SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.login, u.fk_soc, u.datec, u.statut";
112 $sql .=
", u.entity";
113 $sql .=
", u.ldap_sid";
117 $sql .=
", s.nom as name";
118 $sql .=
", s.code_client";
119 $sql .=
", s.canvas";
120 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
121 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON u.fk_soc = s.rowid";
123 $parameters = array();
124 $reshook = $hookmanager->executeHooks(
'printUserListWhere', $parameters);
126 $sql .= $hookmanager->resPrint;
128 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
130 if (!empty($socid)) {
131 $sql .=
" AND u.fk_soc = ".((int) $socid);
133 $sql .= $db->order(
"u.datec",
"DESC");
134 $sql .= $db->plimit($max);
136 $resql = $db->query($sql);
138 $num = $db->num_rows(
$resql);
140 $lastcreatedbox .=
'<div class="div-table-responsive-no-min">';
141 $lastcreatedbox .=
'<table class="noborder centpercent">';
142 $lastcreatedbox .=
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"LastUsersCreated", min($num, $max)).
'</td>';
143 $lastcreatedbox .=
'<td class="right" colspan="2"><a class="commonlink" href="'.DOL_URL_ROOT.
'/user/list.php?sortfield=u.datec&sortorder=DESC">'.$langs->trans(
"FullList").
'</td>';
144 $lastcreatedbox .=
'</tr>'.
"\n";
147 while ($i < $num && $i < $max) {
148 $obj = $db->fetch_object(
$resql);
150 $fuserstatic->id = $obj->rowid;
151 $fuserstatic->statut = $obj->statut;
152 $fuserstatic->lastname = $obj->lastname;
153 $fuserstatic->firstname = $obj->firstname;
154 $fuserstatic->login = $obj->login;
155 $fuserstatic->photo = $obj->photo;
156 $fuserstatic->admin = $obj->admin;
157 $fuserstatic->email = $obj->email;
158 $fuserstatic->socid = $obj->fk_soc;
160 $companystatic->id = $obj->fk_soc;
161 $companystatic->name = $obj->name;
162 $companystatic->code_client = $obj->code_client;
163 $companystatic->canvas = $obj->canvas;
165 $lastcreatedbox .=
'<tr class="oddeven">';
166 $lastcreatedbox .=
'<td class="nowraponall tdoverflowmax150">';
167 $lastcreatedbox .= $fuserstatic->getNomUrl(-1);
168 if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) {
169 $lastcreatedbox .=
img_picto($langs->trans(
"SuperAdministrator"),
'redstar');
170 } elseif ($obj->admin) {
171 $lastcreatedbox .=
img_picto($langs->trans(
"Administrator"),
'star');
173 $lastcreatedbox .=
"</td>";
174 $lastcreatedbox .=
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->login).
'">'.
dol_escape_htmltag($obj->login).
'</td>';
177 $texttoshow .= $companystatic->getNomUrl(1);
179 $texttoshow .=
'<span class="opacitymedium">'.$langs->trans(
"InternalUser").
'</span>';
181 if ($obj->ldap_sid) {
182 $texttoshow .=
' <span class="opacitymedium">('.$langs->trans(
"DomainUser").
')</span>';
184 $entity = $obj->entity;
187 if (!empty($conf->multicompany->enabled) && is_object($mc)) {
188 if (empty($entity)) {
189 $entitystring = $langs->trans(
"AllEntities");
191 $mc->getInfo($entity);
192 $entitystring = $mc->label;
195 $texttoshow .= ($entitystring ?
' <span class="opacitymedium">('.$entitystring.
')</span>' :
'');
196 $lastcreatedbox .=
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag(
dol_string_nohtmltag($texttoshow)).
'">';
197 $lastcreatedbox .= $texttoshow;
198 $lastcreatedbox .=
'</td>';
199 $lastcreatedbox .=
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec),
'dayhour').
'</td>';
200 $lastcreatedbox .=
'<td class="right">';
201 $lastcreatedbox .= $fuserstatic->getLibStatut(3);
202 $lastcreatedbox .=
'</td>';
204 $lastcreatedbox .=
'</tr>';
207 $lastcreatedbox .=
"</table>";
208 $lastcreatedbox .=
"</div><br>";
223 $sql =
"SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec";
224 $sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as g";
225 if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) {
226 $sql .=
" WHERE g.entity IS NOT NULL";
228 $sql .=
" WHERE g.entity IN (0,".$conf->entity.
")";
230 $sql .= $db->order(
"g.datec",
"DESC");
231 $sql .= $db->plimit($max);
233 $resql = $db->query($sql);
236 if (!empty($conf->multicompany->enabled)) {
239 $num = $db->num_rows(
$resql);
241 $lastgroupbox .=
'<div class="div-table-responsive-no-min">';
242 $lastgroupbox .=
'<table class="noborder centpercent">';
243 $lastgroupbox .=
'<tr class="liste_titre"><td colspan="'.$colspan.
'">'.$langs->trans(
"LastGroupsCreated", ($num ? $num : $max)).
'</td>';
244 $lastgroupbox .=
'<td class="right"><a class="commonlink" href="'.DOL_URL_ROOT.
'/user/group/list.php?sortfield=g.datec&sortorder=DESC">'.$langs->trans(
"FullList").
'</td>';
245 $lastgroupbox .=
'</tr>';
250 while ($i < $num && (!$max || $i < $max)) {
251 $obj = $db->fetch_object(
$resql);
253 $grouptemp->id = $obj->rowid;
254 $grouptemp->name = $obj->name;
255 $grouptemp->note = $obj->note;
257 $lastgroupbox .=
'<tr class="oddeven">';
258 $lastgroupbox .=
'<td>';
259 $lastgroupbox .= $grouptemp->getNomUrl(1);
261 $lastgroupbox .=
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
263 $lastgroupbox .=
"</td>";
264 if (!empty($conf->multicompany->enabled) && is_object($mc)) {
265 $mc->getInfo($obj->entity);
266 $lastgroupbox .=
'<td>';
267 $lastgroupbox .= $mc->label;
268 $lastgroupbox .=
'</td>';
270 $lastgroupbox .=
'<td class="nowrap right">'.dol_print_date($db->jdate($obj->datec),
'dayhour').
'</td>';
271 $lastgroupbox .=
"</tr>";
274 $lastgroupbox .=
"</table>";
275 $lastgroupbox .=
"</div><br>";
284 print
'<div class="clearboth"></div>';
285 print
'<div class="fichecenter fichecenterbis">';
287 $boxlist =
'<div class="twocolumns">';
289 $boxlist .=
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
290 $boxlist .= $searchbox;
291 $boxlist .= $resultboxes[
'boxlista'];
292 $boxlist .=
'</div>'.
"\n";
294 $boxlist .=
'<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
295 $boxlist .= $lastcreatedbox;
296 $boxlist .= $lastgroupbox;
297 $boxlist .= $resultboxes[
'boxlistb'];
298 $boxlist .=
'</div>'.
"\n";
300 $boxlist .=
'</div>';
307 $parameters = array(
'user' => $user);
308 $reshook = $hookmanager->executeHooks(
'dashboardUsersGroups', $parameters, $object);