dolibarr  13.0.2
home.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
25 require '../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
27 
28 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userhome'; // To manage different context of search
29 
30 if (!$user->rights->user->user->lire && !$user->admin)
31 {
32  // Redirection vers la page de l'utilisateur
33  header("Location: card.php?id=".$user->id);
34  exit;
35 }
36 
37 // Load translation files required by page
38 $langs->load("users");
39 
40 $canreadperms = true;
41 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
42 {
43  $canreadperms = ($user->admin || $user->rights->user->group_advance->read);
44 }
45 
46 // Security check (for external users)
47 $socid = 0;
48 if ($user->socid > 0) $socid = $user->socid;
49 
50 $companystatic = new Societe($db);
51 $fuserstatic = new User($db);
52 
53 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
54 $hookmanager->initHooks(array('userhome'));
55 
56 
57 /*
58  * View
59  */
60 
61 llxHeader();
62 
63 
64 print load_fiche_titre($langs->trans("MenuUsersAndGroups"), '', 'user');
65 
66 
67 print '<div class="fichecenter"><div class="fichethirdleft">';
68 
69 
70 // Search User
71 print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
72 print '<input type="hidden" name="token" value="'.newToken().'">';
73 
74 print '<table class="noborder nohover centpercent">';
75 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Search").'</td></tr>';
76 print '<tr><td>';
77 print $langs->trans("User").':</td><td><input class="flat inputsearch" type="text" name="search_user" size="18"></td></tr>';
78 
79 // Search Group
80 if ($canreadperms)
81 {
82  print '<tr><td>';
83  print $langs->trans("Group").':</td><td><input class="flat inputsearch" type="text" name="search_group" size="18"></td></tr>';
84 }
85 
86 print '<tr><td class="center" colspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
87 print "</table><br>\n";
88 
89 print '</form>';
90 
91 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
92 
93 
94 /*
95  * Latest created users
96  */
97 $max = 10;
98 
99 $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.login, u.fk_soc, u.datec, u.statut";
100 $sql .= ", u.entity";
101 $sql .= ", u.ldap_sid";
102 $sql .= ", u.photo";
103 $sql .= ", u.admin";
104 $sql .= ", u.email";
105 $sql .= ", s.nom as name";
106 $sql .= ", s.code_client";
107 $sql .= ", s.canvas";
108 $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
109 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
110 // Add fields from hooks
111 $parameters = array();
112 $reshook = $hookmanager->executeHooks('printUserListWhere', $parameters); // Note that $action and $object may have been modified by hook
113 if ($reshook > 0) {
114  $sql .= $hookmanager->resPrint;
115 } else {
116  $sql .= " WHERE u.entity IN (".getEntity('user').")";
117 }
118 if (!empty($socid)) $sql .= " AND u.fk_soc = ".$socid;
119 $sql .= $db->order("u.datec", "DESC");
120 $sql .= $db->plimit($max);
121 
122 $resql = $db->query($sql);
123 if ($resql)
124 {
125  $num = $db->num_rows($resql);
126 
127  print '<div class="div-table-responsive-no-min">';
128  print '<table class="noborder centpercent">';
129  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("LastUsersCreated", min($num, $max)).'</td>';
130  print '<td class="right" colspan="2"><a class="commonlink" href="'.DOL_URL_ROOT.'/user/list.php?sortfield=u.datec&sortorder=DESC">'.$langs->trans("FullList").'</td>';
131  print '</tr>'."\n";
132  $i = 0;
133 
134  while ($i < $num && $i < $max)
135  {
136  $obj = $db->fetch_object($resql);
137 
138  $fuserstatic->id = $obj->rowid;
139  $fuserstatic->statut = $obj->statut;
140  $fuserstatic->lastname = $obj->lastname;
141  $fuserstatic->firstname = $obj->firstname;
142  $fuserstatic->login = $obj->login;
143  $fuserstatic->photo = $obj->photo;
144  $fuserstatic->admin = $obj->admin;
145  $fuserstatic->email = $obj->email;
146  $fuserstatic->socid = $obj->fk_soc;
147 
148  $companystatic->id = $obj->fk_soc;
149  $companystatic->name = $obj->name;
150  $companystatic->code_client = $obj->code_client;
151  $companystatic->canvas = $obj->canvas;
152 
153  print '<tr class="oddeven">';
154  print '<td class="nowraponall">';
155  print $fuserstatic->getNomUrl(-1);
156  if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity)
157  {
158  print img_picto($langs->trans("SuperAdministrator"), 'redstar');
159  } elseif ($obj->admin)
160  {
161  print img_picto($langs->trans("Administrator"), 'star');
162  }
163  print "</td>";
164  print '<td>'.$obj->login.'</td>';
165  print "<td>";
166  if ($obj->fk_soc)
167  {
168  print $companystatic->getNomUrl(1);
169  } else {
170  print $langs->trans("InternalUser");
171  }
172  if ($obj->ldap_sid)
173  {
174  print ' ('.$langs->trans("DomainUser").')';
175  }
176 
177  $entity = $obj->entity;
178  $entitystring = '';
179  // TODO Set of entitystring should be done with a hook
180  if (!empty($conf->multicompany->enabled) && is_object($mc))
181  {
182  if (empty($entity))
183  {
184  $entitystring = $langs->trans("AllEntities");
185  } else {
186  $mc->getInfo($entity);
187  $entitystring = $mc->label;
188  }
189  }
190  print ($entitystring ? ' ('.$entitystring.')' : '');
191 
192  print '</td>';
193  print '<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour').'</td>';
194  print '<td class="right">';
195  print $fuserstatic->getLibStatut(3);
196  print '</td>';
197 
198  print '</tr>';
199  $i++;
200  }
201  print "</table>";
202  print "</div><br>";
203 
204  $db->free($resql);
205 } else {
206  dol_print_error($db);
207 }
208 
209 
210 /*
211  * Last groups created
212  */
213 if ($canreadperms)
214 {
215  $max = 5;
216 
217  $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec";
218  $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
219  if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity)))
220  {
221  $sql .= " WHERE g.entity IS NOT NULL";
222  } else {
223  $sql .= " WHERE g.entity IN (0,".$conf->entity.")";
224  }
225  $sql .= $db->order("g.datec", "DESC");
226  $sql .= $db->plimit($max);
227 
228  $resql = $db->query($sql);
229  if ($resql)
230  {
231  $colspan = 1;
232  if (!empty($conf->multicompany->enabled)) $colspan++;
233  $num = $db->num_rows($resql);
234 
235  print '<div class="div-table-responsive-no-min">';
236  print '<table class="noborder centpercent">';
237  print '<tr class="liste_titre"><td colspan="'.$colspan.'">'.$langs->trans("LastGroupsCreated", ($num ? $num : $max)).'</td>';
238  print '<td class="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/user/group/list.php?sortfield=g.datec&sortorder=DESC">'.$langs->trans("FullList").'</td>';
239  print '</tr>';
240  $i = 0;
241 
242  $grouptemp = new UserGroup($db);
243 
244  while ($i < $num && (!$max || $i < $max))
245  {
246  $obj = $db->fetch_object($resql);
247 
248  $grouptemp->id = $obj->rowid;
249  $grouptemp->name = $obj->name;
250  $grouptemp->note = $obj->note;
251 
252  print '<tr class="oddeven">';
253  print '<td>';
254  print $grouptemp->getNomUrl(1);
255  if (!$obj->entity)
256  {
257  print img_picto($langs->trans("GlobalGroup"), 'redstar');
258  }
259  print "</td>";
260  if (!empty($conf->multicompany->enabled) && is_object($mc))
261  {
262  $mc->getInfo($obj->entity);
263  print '<td>';
264  print $mc->label;
265  print '</td>';
266  }
267  print '<td class="nowrap right">'.dol_print_date($db->jdate($obj->datec), 'dayhour').'</td>';
268  print "</tr>";
269  $i++;
270  }
271  print "</table>";
272  print "</div><br>";
273 
274  $db->free($resql);
275  } else {
276  dol_print_error($db);
277  }
278 }
279 
280 //print '</td></tr></table>';
281 print '</div></div></div>';
282 
283 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
284 $parameters = array('user' => $user);
285 $reshook = $hookmanager->executeHooks('dashboardUsersGroups', $parameters, $object); // Note that $action and $object may have been modified by hook
286 
287 // End of page
288 llxFooter();
289 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
Definition: user.class.php:44
Class to manage user groups.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59