dolibarr  17.0.4
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2022 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
6  * Copyright (C) 2005-2021 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
8  * Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
9  * Copyright (C) 2012-2018 Juanjo Menent <jmenent@2byte.es>
10  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
11  * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
12  * Copyright (C) 2015-2017 Jean-François Ferry <jfefe@aternatik.fr>
13  * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
14  * Copyright (C) 2015-2018 Charlene Benke <charlie@patas-monkey.com>
15  * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
16  * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
17  * Copyright (C) 2018 David Beniamine <David.Beniamine@Tetras-Libre.fr>
18  *
19  * This program is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <https://www.gnu.org/licenses/>.
31  */
32 
38 // Load Dolibarr environment
39 require '../main.inc.php';
40 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
45 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
48 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
49 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
50 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
52 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
53 if (!empty($conf->ldap->enabled)) {
54  require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
55 }
56 if (isModEnabled('adherent')) {
57  require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
58 }
59 if (isModEnabled('categorie')) {
60  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
61 }
62 if (isModEnabled('stock')) {
63  require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
64 }
65 
66 // Load translation files required by page
67 $langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm', 'stocks', 'other'));
68 
69 $id = GETPOST('id', 'int');
70 $action = GETPOST('action', 'aZ09');
71 $mode = GETPOST('mode', 'alpha');
72 $confirm = GETPOST('confirm', 'alpha');
73 $group = GETPOST("group", "int", 3);
74 $cancel = GETPOST('cancel', 'alpha');
75 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search
76 
77 $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth', 'int'), GETPOST('dateemploymentday', 'int'), GETPOST('dateemploymentyear', 'int'));
78 $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int'));
79 $datestartvalidity = dol_mktime(0, 0, 0, GETPOST('datestartvaliditymonth', 'int'), GETPOST('datestartvalidityday', 'int'), GETPOST('datestartvalidityyear', 'int'));
80 $dateendvalidity = dol_mktime(0, 0, 0, GETPOST('dateendvaliditymonth', 'int'), GETPOST('dateendvalidityday', 'int'), GETPOST('dateendvalidityyear', 'int'));
81 $dateofbirth = dol_mktime(0, 0, 0, GETPOST('dateofbirthmonth', 'int'), GETPOST('dateofbirthday', 'int'), GETPOST('dateofbirthyear', 'int'));
82 
83 $childids = $user->getAllChildIds(1); // For later, test on salary visibility
84 
85 $object = new User($db);
86 $extrafields = new ExtraFields($db);
87 
88 // fetch optionals attributes and labels
89 $extrafields->fetch_name_optionals_label($object->table_element);
90 
91 $socialnetworks = getArrayOfSocialNetworks();
92 
93 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
94 $hookmanager->initHooks(array('usercard', 'globalcard'));
95 
96 $error = 0;
97 
98 $acceptlocallinktomedia = (acceptLocalLinktoMedia() > 0 ? 1 : 0);
99 
100 if ($id > 0) {
101  $res = $object->fetch($id, '', '', 1);
102 }
103 
104 // Security check
105 $socid = 0;
106 if ($user->socid > 0) {
107  $socid = $user->socid;
108 }
109 $feature2 = 'user';
110 $result = restrictedArea($user, 'user', $id, 'user', $feature2);
111 
112 // Define value to know what current user can do on users
113 $canadduser = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
114 $canreaduser = (!empty($user->admin) || $user->hasRight("user", "user", "read"));
115 $canedituser = (!empty($user->admin) || $user->hasRight("user", "user", "write")); // edit other user
116 $candisableuser = (!empty($user->admin) || $user->hasRight("user", "user", "delete"));
117 $canreadgroup = $canreaduser;
118 $caneditgroup = $canedituser;
119 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
120  $canreadgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "read"));
121  $caneditgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "write"));
122 }
123 
124 if ($user->id != $id && !$canreaduser) {
125  accessforbidden();
126 }
127 
128 // Define value to know what current user can do on properties of edited user
129 if ($id > 0) {
130  // $user is the current logged user, $id is the user we want to edit
131  $canedituser = (($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write"));
132  $caneditfield = ((($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write")));
133  $caneditpassword = ((($user->id == $id) && $user->hasRight("user", "self", "password")) || (($user->id != $id) && $user->hasRight("user", "user", "password")));
134 }
135 
136 
141 $parameters = array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup);
142 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
143 if ($reshook < 0) {
144  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
145 }
146 
147 if (empty($reshook)) {
148  $backurlforlist = DOL_URL_ROOT.'/user/list.php';
149 
150  if (empty($backtopage) || ($cancel && empty($id))) {
151  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
152  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
153  $backtopage = $backurlforlist;
154  } else {
155  $backtopage = DOL_URL_ROOT.'/user/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
156  }
157  }
158  }
159 
160  if ($cancel) {
161  if (!empty($backtopageforcancel)) {
162  header("Location: ".$backtopageforcancel);
163  exit;
164  } elseif (!empty($backtopage)) {
165  header("Location: ".$backtopage);
166  exit;
167  }
168  $action = '';
169  }
170 
171  if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) {
172  if ($id != $user->id) { // A user can't disable itself
173  $object->fetch($id);
174  if ($object->admin && empty($user->admin)) {
175  // If user to delete is an admin user and if logged user is not admin, we deny the operation.
176  $error++;
177  setEventMessages($langs->trans("OnlyAdminUsersCanDisableAdminUsers"), null, 'errors');
178  } else {
179  $object->setstatus(0);
180  header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
181  exit;
182  }
183  }
184  }
185 
186  if ($action == 'confirm_enable' && $confirm == "yes" && $candisableuser) {
187  $error = 0;
188 
189  if ($id != $user->id) {
190  $object->fetch($id);
191 
192  if (!empty($conf->file->main_limit_users)) {
193  $nb = $object->getNbOfUsers("active");
194  if ($nb >= $conf->file->main_limit_users) {
195  $error++;
196  setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors');
197  }
198  }
199 
200  if (!$error) {
201  $object->setstatus(1);
202  header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
203  exit;
204  }
205  }
206  }
207 
208  if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) {
209  if ($id != $user->id) {
210  if (!GETPOSTISSET('token')) {
211  print 'Error, token required for this critical operation';
212  exit;
213  }
214 
215  $object = new User($db);
216  $object->fetch($id);
217  $object->oldcopy = clone $object;
218 
219  $result = $object->delete($user);
220  if ($result < 0) {
221  $langs->load("errors");
222  setEventMessages($langs->trans("ErrorUserCannotBeDelete"), null, 'errors');
223  } else {
224  setEventMessages($langs->trans("RecordDeleted"), null);
225  header("Location: ".DOL_URL_ROOT."/user/list.php?restore_lastsearch_values=1");
226  exit;
227  }
228  }
229  }
230 
231  // Action Add user
232  if ($action == 'add' && $canadduser) {
233  $error = 0;
234 
235  if (!GETPOST("lastname")) {
236  $error++;
237  setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
238  $action = "create"; // Go back to create page
239  }
240  if (!GETPOST("login")) {
241  $error++;
242  setEventMessages($langs->trans("LoginNotDefined"), null, 'errors');
243  $action = "create"; // Go back to create page
244  }
245 
246  if (!empty($conf->file->main_limit_users)) { // If option to limit users is set
247  $nb = $object->getNbOfUsers("active");
248  if ($nb >= $conf->file->main_limit_users) {
249  $error++;
250  setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors');
251  $action = "create"; // Go back to create page
252  }
253  }
254 
255  if (!$error) {
256  $object->civility_code = GETPOST("civility_code", 'aZ09');
257  $object->lastname = GETPOST("lastname", 'alphanohtml');
258  $object->firstname = GETPOST("firstname", 'alphanohtml');
259  $object->ref_employee = GETPOST("ref_employee", 'alphanohtml');
260  $object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml');
261  $object->login = GETPOST("login", 'alphanohtml');
262  $object->api_key = GETPOST("api_key", 'alphanohtml');
263  $object->gender = GETPOST("gender", 'aZ09');
264  $object->admin = GETPOST("admin", 'int');
265  $object->address = GETPOST('address', 'alphanohtml');
266  $object->zip = GETPOST('zipcode', 'alphanohtml');
267  $object->town = GETPOST('town', 'alphanohtml');
268  $object->country_id = GETPOST('country_id', 'int');
269  $object->state_id = GETPOST('state_id', 'int');
270  $object->office_phone = GETPOST("office_phone", 'alphanohtml');
271  $object->office_fax = GETPOST("office_fax", 'alphanohtml');
272  $object->user_mobile = GETPOST("user_mobile", 'alphanohtml');
273 
274  if (isModEnabled('socialnetworks')) {
275  $object->socialnetworks = array();
276  foreach ($socialnetworks as $key => $value) {
277  if (GETPOST($key, 'alphanohtml')) {
278  $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
279  }
280  }
281  }
282 
283  $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml'));
284  $object->job = GETPOST("job", 'alphanohtml');
285  $object->signature = GETPOST("signature", 'restricthtml');
286  $object->accountancy_code = GETPOST("accountancy_code", 'alphanohtml');
287  $object->note_public = GETPOST("note_public", 'restricthtml');
288  $object->note_private = GETPOST("note_private", 'restricthtml');
289  $object->ldap_sid = GETPOST("ldap_sid", 'alphanohtml');
290  $object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", 'int') : 0;
291  $object->fk_user_expense_validator = GETPOST("fk_user_expense_validator", 'int') > 0 ? GETPOST("fk_user_expense_validator", 'int') : 0;
292  $object->fk_user_holiday_validator = GETPOST("fk_user_holiday_validator", 'int') > 0 ? GETPOST("fk_user_holiday_validator", 'int') : 0;
293  $object->employee = GETPOST('employee', 'alphanohtml');
294 
295  $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : '';
296  $object->thm = price2num($object->thm);
297  $object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : '';
298  $object->tjm = price2num($object->tjm);
299  $object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : '';
300  $object->salary = price2num($object->salary);
301  $object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : '';
302  $object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : '';
303 
304  $object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : '';
305 
306  $object->dateemployment = $dateemployment;
307  $object->dateemploymentend = $dateemploymentend;
308  $object->datestartvalidity = $datestartvalidity;
309  $object->dateendvalidity = $dateendvalidity;
310  $object->birth = $dateofbirth;
311 
312  $object->fk_warehouse = GETPOST('fk_warehouse', 'int');
313 
314  $object->lang = GETPOST('default_lang', 'aZ09');
315 
316  // Fill array 'array_options' with data from add form
317  $ret = $extrafields->setOptionalsFromPost(null, $object);
318  if ($ret < 0) {
319  $error++;
320  }
321 
322  // Set entity property
323  $entity = GETPOST('entity', 'int');
324  if (isModEnabled('multicompany')) {
325  if (GETPOST('superadmin', 'int')) {
326  $object->entity = 0;
327  } else {
328  if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
329  $object->entity = 1; // all users are forced into master entity
330  } else {
331  $object->entity = ($entity == '' ? 1 : $entity);
332  }
333  }
334  } else {
335  $object->entity = ($entity == '' ? 1 : $entity);
336  /*if ($user->admin && $user->entity == 0 && GETPOST("admin",'alpha'))
337  {
338  }*/
339  }
340 
341  $db->begin();
342 
343  $id = $object->create($user);
344  if ($id > 0) {
345  $resPass = 0;
346  if (GETPOST('password', 'none')) {
347  $resPass = $object->setPassword($user, GETPOST('password', 'none'));
348  }
349  if ($resPass < 0) {
350  $langs->load("errors");
351  $db->rollback();
352  setEventMessages($object->error, $object->errors, 'errors');
353  $action = "create"; // Go back to create page
354  } else {
355  if (!empty($conf->categorie->enabled)) {
356  // Categories association
357  $usercats = GETPOST('usercats', 'array');
358  $object->setCategories($usercats);
359  }
360  $db->commit();
361 
362  header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
363  exit;
364  }
365  } else {
366  $langs->load("errors");
367  $db->rollback();
368  setEventMessages($object->error, $object->errors, 'errors');
369  $action = "create"; // Go back to create page
370  }
371  }
372  }
373 
374  // Action add usergroup
375  if (($action == 'addgroup' || $action == 'removegroup') && $caneditgroup) {
376  if ($group) {
377  $editgroup = new UserGroup($db);
378  $editgroup->fetch($group);
379  $editgroup->oldcopy = clone $editgroup;
380 
381  $object->fetch($id);
382  if ($action == 'addgroup') {
383  $result = $object->SetInGroup($group, $editgroup->entity);
384  }
385  if ($action == 'removegroup') {
386  $result = $object->RemoveFromGroup($group, $editgroup->entity);
387  }
388 
389  if ($result > 0) {
390  $action = '';
391  } else {
392  setEventMessages($object->error, $object->errors, 'errors');
393  }
394  }
395  }
396 
397  if ($action == 'update' && $canedituser) {
398  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
399 
400  if ($caneditfield) { // Case we can edit all field
401  $error = 0;
402 
403  if (!GETPOST("lastname", 'alpha')) {
404  setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
405  $action = "edit"; // Go back to create page
406  $error++;
407  }
408  if (!GETPOST("login", 'alpha')) {
409  setEventMessages($langs->trans("LoginNotDefined"), null, 'errors');
410  $action = "edit"; // Go back to create page
411  $error++;
412  }
413 
414  if (!$error) {
415  $object->fetch($id);
416 
417  $object->oldcopy = clone $object;
418 
419  $db->begin();
420 
421  $object->civility_code = GETPOST("civility_code", 'aZ09');
422  $object->lastname = GETPOST("lastname", 'alphanohtml');
423  $object->firstname = GETPOST("firstname", 'alphanohtml');
424  /*
425  * Protection against deletion of ref_employee while the field is not present in the user tab
426  */
427  if (GETPOSTISSET("ref_employee")) {
428  $object->ref_employee = GETPOST("ref_employee", 'alphanohtml');
429  }
430  /*
431  * Protection against deletion of national_registration_number while the field is not present in the user tab
432  */
433  if (GETPOSTISSET("national_registration_number")) {
434  $object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml');
435  }
436  $object->gender = GETPOST("gender", 'aZ09');
437  if ($caneditpassword) {
438  $object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields
439  }
440  if ($caneditpassword || $user->hasRight("api", "apikey", "generate")) {
441  $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key;
442  }
443  if (!empty($user->admin)) { // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request
444  $object->admin = GETPOST("admin", "int");
445  }
446  if ($user->admin && !$object->ldap_sid) { // same test than on edit page
447  $object->login = GETPOST("login", 'alphanohtml');
448  }
449  $object->address = GETPOST('address', 'alphanohtml');
450  $object->zip = GETPOST('zipcode', 'alphanohtml');
451  $object->town = GETPOST('town', 'alphanohtml');
452  $object->country_id = GETPOST('country_id', 'int');
453  $object->state_id = GETPOST('state_id', 'int');
454  $object->office_phone = GETPOST("office_phone", 'alphanohtml');
455  $object->office_fax = GETPOST("office_fax", 'alphanohtml');
456  $object->user_mobile = GETPOST("user_mobile", 'alphanohtml');
457 
458  if (isModEnabled('socialnetworks')) {
459  $object->socialnetworks = array();
460  foreach ($socialnetworks as $key => $value) {
461  if (GETPOST($key, 'alphanohtml')) {
462  $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
463  }
464  }
465  }
466 
467  $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml'));
468  $object->job = GETPOST("job", 'alphanohtml');
469  $object->signature = GETPOST("signature", 'restricthtml');
470  $object->accountancy_code = GETPOST("accountancy_code", 'alphanohtml');
471  $object->openid = GETPOST("openid", 'alphanohtml');
472  $object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", 'int') : 0;
473  $object->fk_user_expense_validator = GETPOST("fk_user_expense_validator", 'int') > 0 ? GETPOST("fk_user_expense_validator", 'int') : 0;
474  $object->fk_user_holiday_validator = GETPOST("fk_user_holiday_validator", 'int') > 0 ? GETPOST("fk_user_holiday_validator", 'int') : 0;
475  $object->employee = GETPOST('employee', 'int');
476 
477  $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : '';
478  $object->thm = price2num($object->thm);
479  $object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : '';
480  $object->thm = price2num($object->thm);
481  $object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : '';
482  $object->salary = price2num($object->salary);
483  $object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : '';
484  $object->salaryextra = price2num($object->salaryextra);
485  $object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : '';
486  $object->weeklyhours = price2num($object->weeklyhours);
487 
488  $object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : '';
489  $object->dateemployment = $dateemployment;
490  $object->dateemploymentend = $dateemploymentend;
491  $object->datestartvalidity = $datestartvalidity;
492  $object->dateendvalidity = $dateendvalidity;
493  $object->birth = $dateofbirth;
494 
495  if (isModEnabled('stock')) {
496  $object->fk_warehouse = GETPOST('fk_warehouse', 'int');
497  }
498 
499  $object->lang = GETPOST('default_lang', 'aZ09');
500 
501  // Do we update also ->entity ?
502  if (isModEnabled('multicompany') && empty($user->entity) && !empty($user->admin)) { // If multicompany is not enabled, we never update the entity of a user.
503  if (GETPOST('superadmin', 'int')) {
504  $object->entity = 0;
505  } else {
506  if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
507  $object->entity = 1; // all users are in master entity
508  } else {
509  // We try to change the entity of user
510  $object->entity = (GETPOSTISSET('entity') ? GETPOSTINT('entity') : $object->entity);
511  }
512  }
513  }
514 
515  // Fill array 'array_options' with data from add form
516  $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
517  if ($ret < 0) {
518  $error++;
519  }
520 
521  if (GETPOST('deletephoto')) {
522  $object->photo = '';
523  }
524  if (!empty($_FILES['photo']['name'])) {
525  $isimage = image_format_supported($_FILES['photo']['name']);
526  if ($isimage > 0) {
527  $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
528  } else {
529  $error++;
530  $langs->load("errors");
531  setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
532  dol_syslog($langs->transnoentities("ErrorBadImageFormat"), LOG_INFO);
533  }
534  }
535 
536  if (!$error) {
537  $ret = $object->update($user); // This may include call to setPassword if password has changed
538  if ($ret < 0) {
539  $error++;
540  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
541  $langs->load("errors");
542  setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors');
543  } else {
544  setEventMessages($object->error, $object->errors, 'errors');
545  $action = 'edit';
546  }
547  }
548  }
549 
550  if (!$error && GETPOSTISSET('contactid')) {
551  $contactid = GETPOST('contactid', 'int');
552  $socid = GETPOST('socid', 'int');
553 
554  if ($contactid > 0) { // The 'contactid' is used inpriority over the 'socid'
555  $contact = new Contact($db);
556  $contact->fetch($contactid);
557 
558  $sql = "UPDATE ".MAIN_DB_PREFIX."user";
559  $sql .= " SET fk_socpeople=".((int) $contactid);
560  if (!empty($contact->socid)) {
561  $sql .= ", fk_soc=".((int) $contact->socid);
562  } elseif ($socid > 0) {
563  $sql .= ", fk_soc = null";
564  setEventMessages($langs->trans("WarningUserDifferentContactSocid"), '', 'warnings'); // Add message if post socid != $contact->socid
565  }
566  $sql .= " WHERE rowid = ".((int) $object->id);
567  } elseif ($socid > 0) {
568  $sql = "UPDATE ".MAIN_DB_PREFIX."user";
569  $sql .= " SET fk_socpeople=NULL, fk_soc=".((int) $socid);
570  $sql .= " WHERE rowid = ".((int) $object->id);
571  } else {
572  $sql = "UPDATE ".MAIN_DB_PREFIX."user";
573  $sql .= " SET fk_socpeople=NULL, fk_soc=NULL";
574  $sql .= " WHERE rowid = ".((int) $object->id);
575  }
576  dol_syslog("usercard::update", LOG_DEBUG);
577  $resql = $db->query($sql);
578  if (!$resql) {
579  $error++;
580  setEventMessages($db->lasterror(), null, 'errors');
581  }
582  }
583 
584  if (!$error && !count($object->errors)) {
585  if (GETPOST('deletephoto') && $object->oldcopy->photo) {
586  $fileimg = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->oldcopy->photo;
587  $dirthumbs = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'photos/thumbs';
588  dol_delete_file($fileimg);
589  dol_delete_dir_recursive($dirthumbs);
590  }
591 
592  if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) {
593  $dir = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'user').'/photos';
594 
595  dol_mkdir($dir);
596 
597  if (@is_dir($dir)) {
598  $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
599  $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']);
600 
601  if (!($result > 0)) {
602  setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
603  } else {
604  // Create thumbs
605  $object->addThumbs($newfile);
606  }
607  } else {
608  $error++;
609  $langs->load("errors");
610  setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors');
611  }
612  }
613  }
614 
615  if (!$error && !count($object->errors)) {
616  // Then we add the associated categories
617  $categories = GETPOST('usercats', 'array');
618  $object->setCategories($categories);
619  }
620 
621  if (!$error && !count($object->errors)) {
622  setEventMessages($langs->trans("UserModified"), null, 'mesgs');
623  $db->commit();
624 
625  $login = $_SESSION["dol_login"];
626  if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) { // Current user has changed its login
627  $error++;
628  $langs->load("errors");
629  setEventMessages($langs->transnoentitiesnoconv("WarningYourLoginWasModifiedPleaseLogin"), null, 'warnings');
630  }
631  } else {
632  $db->rollback();
633  }
634  }
635  } else {
636  if ($caneditpassword) { // Case we can edit only password
637  dol_syslog("Not allowed to change fields, only password");
638 
639  $object->fetch($id);
640 
641  if (GETPOST("password", "none")) { // If pass is empty, we do not change it.
642  $object->oldcopy = clone $object;
643 
644  $ret = $object->setPassword($user, GETPOST("password", "none"));
645  if ($ret < 0) {
646  setEventMessages($object->error, $object->errors, 'errors');
647  }
648  }
649  }
650  }
651  }
652 
653  // Change password with a new generated one
654  if ((($action == 'confirm_password' && $confirm == 'yes')
655  || ($action == 'confirm_passwordsend' && $confirm == 'yes')) && $caneditpassword
656  ) {
657  $object->fetch($id);
658 
659  $newpassword = $object->setPassword($user, ''); // This will generate a new password
660  if ($newpassword < 0) {
661  // Echec
662  setEventMessages($langs->trans("ErrorFailedToSetNewPassword"), null, 'errors');
663  } else {
664  // Succes
665  if ($action == 'confirm_passwordsend' && $confirm == 'yes') {
666  if ($object->send_password($user, $newpassword) > 0) {
667  setEventMessages($langs->trans("PasswordChangedAndSentTo", $object->email), null, 'mesgs');
668  } else {
669  setEventMessages($object->error, $object->errors, 'errors');
670  }
671  } else {
672  setEventMessages($langs->trans("PasswordChangedTo", $newpassword), null, 'warnings');
673  }
674  }
675  }
676 
677  // Action initialisation donnees depuis record LDAP
678  if ($action == 'adduserldap' && $canadduser) {
679  $selecteduser = GETPOST('users');
680 
681  $required_fields = array(
682  $conf->global->LDAP_KEY_USERS,
683  $conf->global->LDAP_FIELD_NAME,
684  $conf->global->LDAP_FIELD_FIRSTNAME,
685  $conf->global->LDAP_FIELD_LOGIN,
686  $conf->global->LDAP_FIELD_LOGIN_SAMBA,
687  $conf->global->LDAP_FIELD_PASSWORD,
688  $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
689  $conf->global->LDAP_FIELD_PHONE,
690  $conf->global->LDAP_FIELD_FAX,
691  $conf->global->LDAP_FIELD_MOBILE,
692  $conf->global->LDAP_FIELD_SKYPE,
693  $conf->global->LDAP_FIELD_MAIL,
694  $conf->global->LDAP_FIELD_TITLE,
695  $conf->global->LDAP_FIELD_DESCRIPTION,
696  $conf->global->LDAP_FIELD_SID
697  );
698 
699  $ldap = new Ldap();
700  $result = $ldap->connect_bind();
701  if ($result >= 0) {
702  // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
703  $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement")));
704 
705  $ldapusers = $ldap->getRecords($selecteduser, $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields);
706  //print_r($ldapusers);
707 
708  if (is_array($ldapusers)) {
709  foreach ($ldapusers as $key => $attribute) {
710  $ldap_lastname = $attribute[$conf->global->LDAP_FIELD_NAME];
711  $ldap_firstname = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME];
712  $ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN];
713  $ldap_loginsmb = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA];
714  $ldap_pass = $attribute[$conf->global->LDAP_FIELD_PASSWORD];
715  $ldap_pass_crypted = $attribute[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED];
716  $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE];
717  $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX];
718  $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE];
719  $ldap_social['skype'] = $attribute[$conf->global->LDAP_FIELD_SKYPE];
720  $ldap_social['twitter'] = $attribute[$conf->global->LDAP_FIELD_TWITTER];
721  $ldap_social['facebook'] = $attribute[$conf->global->LDAP_FIELD_FACEBOOK];
722  $ldap_social['linkedin'] = $attribute[$conf->global->LDAP_FIELD_LINKEDIN];
723  $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL];
724  $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID];
725  }
726  }
727  } else {
728  setEventMessages($ldap->error, $ldap->errors, 'errors');
729  }
730  }
731 
732  // Actions to send emails
733  $triggersendname = 'USER_SENTBYMAIL';
734  $paramname = 'id'; // Name of param key to open the card
735  $mode = 'emailfromuser';
736  $trackid = 'use'.$id;
737  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
738 
739  // Actions to build doc
740  $upload_dir = $conf->user->dir_output;
741  $permissiontoadd = $user->hasRight("user", "user", "write");
742  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
743 }
744 
745 
746 /*
747  * View
748  */
749 
750 $form = new Form($db);
751 $formother = new FormOther($db);
752 $formcompany = new FormCompany($db);
753 $formadmin = new FormAdmin($db);
754 $formfile = new FormFile($db);
755 if (isModEnabled('stock')) {
756  $formproduct = new FormProduct($db);
757 }
758 
759 if ($object->id > 0) {
760  $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
761  $title = $person_name." - ".$langs->trans('Card');
762 } else {
763  $title = $langs->trans("NewUser");
764 }
765 $help_url = '';
766 
767 llxHeader('', $title, $help_url);
768 
769 
770 if ($action == 'create' || $action == 'adduserldap') {
771  print load_fiche_titre($langs->trans("NewUser"), '', 'user');
772 
773  print '<span class="opacitymedium">'.$langs->trans("CreateInternalUserDesc")."</span><br>\n";
774  print "<br>";
775 
776 
777  if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) {
778  // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set
779  $ldap = new Ldap();
780  $result = $ldap->connect_bind();
781  if ($result >= 0) {
782  $required_fields = array(
783  $conf->global->LDAP_KEY_USERS,
784  $conf->global->LDAP_FIELD_FULLNAME,
785  $conf->global->LDAP_FIELD_NAME,
786  $conf->global->LDAP_FIELD_FIRSTNAME,
787  $conf->global->LDAP_FIELD_LOGIN,
788  $conf->global->LDAP_FIELD_LOGIN_SAMBA,
789  $conf->global->LDAP_FIELD_PASSWORD,
790  $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
791  $conf->global->LDAP_FIELD_PHONE,
792  $conf->global->LDAP_FIELD_FAX,
793  $conf->global->LDAP_FIELD_MOBILE,
794  $conf->global->LDAP_FIELD_SKYPE,
795  $conf->global->LDAP_FIELD_MAIL,
796  $conf->global->LDAP_FIELD_TITLE,
797  $conf->global->LDAP_FIELD_DESCRIPTION,
798  $conf->global->LDAP_FIELD_SID
799  );
800 
801  // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
802  $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement")));
803 
804  // Get from LDAP database an array of results
805  $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
806 
807  if (is_array($ldapusers)) {
808  $liste = array();
809  foreach ($ldapusers as $key => $ldapuser) {
810  // Define the label string for this user
811  $label = '';
812  foreach ($required_fields as $value) {
813  if ($value === $conf->global->LDAP_FIELD_PASSWORD || $value === $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) {
814  $label .= $value."=******* ";
815  } elseif ($value) {
816  $label .= $value."=".$ldapuser[$value]." ";
817  }
818  }
819  $liste[$key] = $label;
820  }
821  } else {
822  setEventMessages($ldap->error, $ldap->errors, 'errors');
823  }
824  } else {
825  setEventMessages($ldap->error, $ldap->errors, 'errors');
826  }
827 
828  // If user list is full, we show drop-down list
829  print "\n\n<!-- Form liste LDAP debut -->\n";
830 
831  print '<form name="add_user_ldap" action="'.$_SERVER["PHP_SELF"].'" method="post">';
832  print '<input type="hidden" name="token" value="'.newToken().'">';
833  print '<table class="border centpercent"><tr>';
834  print '<td width="160">';
835  print $langs->trans("LDAPUsers");
836  print '</td>';
837  print '<td>';
838  print '<input type="hidden" name="action" value="adduserldap">';
839  if (is_array($liste) && count($liste)) {
840  print $form->selectarray('users', $liste, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth500');
841  print ajax_combobox('users');
842  }
843  print '</td><td class="center">';
844  print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Get')).'"'.(count($liste) ? '' : ' disabled').'>';
845  print '</td></tr></table>';
846  print '</form>';
847 
848  print "\n<!-- Form liste LDAP fin -->\n\n";
849  print '<br>';
850  }
851 
852 
853  print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST" name="createuser">';
854  print '<input type="hidden" name="token" value="'.newToken().'">';
855  print '<input type="hidden" name="action" value="add">';
856  if (!empty($ldap_sid)) {
857  print '<input type="hidden" name="ldap_sid" value="'.dol_escape_htmltag($ldap_sid).'">';
858  }
859  print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
860 
861  print dol_get_fiche_head('', '', '', 0, '');
862 
863  dol_set_focus('#lastname');
864 
865  print '<table class="border centpercent">';
866 
867  // Civility
868  print '<tr><td><label for="civility_code">'.$langs->trans("UserTitle").'</label></td><td>';
869  print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'aZ09') : $object->civility_code, 'civility_code');
870  print '</td></tr>';
871 
872  // Lastname
873  print '<tr>';
874  print '<td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td>';
875  print '<td>';
876  if (!empty($ldap_lastname)) {
877  print '<input type="hidden" id="lastname" name="lastname" value="'.dol_escape_htmltag($ldap_lastname).'">';
878  print $ldap_lastname;
879  } else {
880  print '<input class="minwidth100 maxwidth150onsmartphone" type="text" id="lastname" name="lastname" value="'.dol_escape_htmltag(GETPOST('lastname', 'alphanohtml')).'">';
881  }
882  print '</td></tr>';
883 
884  // Firstname
885  print '<tr><td>'.$langs->trans("Firstname").'</td>';
886  print '<td>';
887  if (!empty($ldap_firstname)) {
888  print '<input type="hidden" name="firstname" value="'.dol_escape_htmltag($ldap_firstname).'">';
889  print $ldap_firstname;
890  } else {
891  print '<input class="minwidth100 maxwidth150onsmartphone" type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST('firstname', 'alphanohtml')).'">';
892  }
893  print '</td></tr>';
894 
895  // Login
896  print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
897  print '<td>';
898  if (!empty($ldap_login)) {
899  print '<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_login).'">';
900  print $ldap_login;
901  } elseif (!empty($ldap_loginsmb)) {
902  print '<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_loginsmb).'">';
903  print $ldap_loginsmb;
904  } else {
905  print '<input class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(GETPOST('login', 'alphanohtml')).'">';
906  }
907  print '</td></tr>';
908 
909  $generated_password = '';
910  if (empty($ldap_sid)) { // ldap_sid is for activedirectory
911  $generated_password = getRandomPassword(false);
912  }
913  $password = (GETPOSTISSET('password') ?GETPOST('password') : $generated_password);
914 
915  // Administrator
916  if (!empty($user->admin)) {
917  print '<tr><td>'.$langs->trans("Administrator").'</td>';
918  print '<td>';
919  print $form->selectyesno('admin', GETPOST('admin'), 1);
920 
921  if (isModEnabled('multicompany') && !$user->entity) {
922  if (!empty($conf->use_javascript_ajax)) {
923  print '<script type="text/javascript">
924  $(function() {
925  $("select[name=admin]").change(function() {
926  if ( $(this).val() == 0 ) {
927  $("input[name=superadmin]")
928  .prop("disabled", true)
929  .prop("checked", false);
930  $("select[name=entity]")
931  .prop("disabled", false);
932  } else {
933  $("input[name=superadmin]")
934  .prop("disabled", false);
935  }
936  });
937  $("input[name=superadmin]").change(function() {
938  if ( $(this).is(":checked") ) {
939  $("select[name=entity]")
940  .prop("disabled", true);
941  } else {
942  $("select[name=entity]")
943  .prop("disabled", false);
944  }
945  });
946  });
947  </script>';
948  }
949  $checked = (GETPOST('superadmin', 'int') ? ' checked' : '');
950  $disabled = (GETPOST('superadmin', 'int') ? '' : ' disabled');
951  print '<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.$disabled.' /> <label for="superadmin">'.$langs->trans("SuperAdministrator").'</span>';
952  }
953  print "</td></tr>\n";
954  }
955 
956  // Gender
957  print '<tr><td>'.$langs->trans("Gender").'</td>';
958  print '<td>';
959  $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
960  print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1);
961  print '</td></tr>';
962 
963  // Employee
964  $defaultemployee = '1';
965  print '<tr>';
966  print '<td>'.$langs->trans('Employee').'</td><td>';
967  print '<input type="checkbox" name="employee" value="1"'.(GETPOST('employee') == '1' ? ' checked="checked"' : (($defaultemployee && !GETPOSTISSET('login')) ? ' checked="checked"' : '')).'>';
968  //print $form->selectyesno("employee", (GETPOST('employee') != '' ?GETPOST('employee') : $defaultemployee), 1);
969  print '</td></tr>';
970 
971  // Hierarchy
972  print '<tr><td class="titlefieldcreate">'.$langs->trans("HierarchicalResponsible").'</td>';
973  print '<td>';
974  print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx');
975  print '</td>';
976  print "</tr>\n";
977 
978  // Expense report validator
979  if (isModEnabled('expensereport')) {
980  print '<tr><td class="titlefieldcreate">';
981  $text = $langs->trans("ForceUserExpenseValidator");
982  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
983  print '</td>';
984  print '<td>';
985  print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx');
986  print '</td>';
987  print "</tr>\n";
988  }
989 
990  // Holiday request validator
991  if (isModEnabled('holiday')) {
992  print '<tr><td class="titlefieldcreate">';
993  $text = $langs->trans("ForceUserHolidayValidator");
994  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
995  print '</td>';
996  print '<td>';
997  print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx');
998  print '</td>';
999  print "</tr>\n";
1000  }
1001 
1002  // External user
1003  print '<tr><td>'.$langs->trans("ExternalUser").' ?</td>';
1004  print '<td>';
1005  print $form->textwithpicto($langs->trans("Internal"), $langs->trans("InternalExternalDesc"), 1, 'help', '', 0, 2);
1006  print '</td></tr>';
1007 
1008 
1009  print '</table><hr><table class="border centpercent">';
1010 
1011 
1012  // Date validity
1013  print '<tr><td class="titlefieldcreate">'.$langs->trans("RangeOfLoginValidity").'</td>';
1014  print '<td>';
1015  print $form->selectDate($datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1);
1016 
1017  print ' &nbsp; ';
1018 
1019  print $form->selectDate($dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0);
1020  print '</td>';
1021  print "</tr>\n";
1022 
1023  // Password
1024  print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td>';
1025  print '<td>';
1026  $valuetoshow = '';
1027  if (preg_match('/ldap/', $dolibarr_main_authentication)) {
1028  $valuetoshow .= ($valuetoshow ? ' + ' : '').$langs->trans("PasswordOfUserInLDAP").' (hidden)';
1029  }
1030  if (preg_match('/http/', $dolibarr_main_authentication)) {
1031  $valuetoshow .= ($valuetoshow ? ' + ' : '').$langs->trans("HTTPBasicPassword");
1032  }
1033  if (preg_match('/dolibarr/', $dolibarr_main_authentication)) {
1034  if (!empty($ldap_pass)) { // For very old system comaptibilty. Now clear password can't be viewed from LDAP read
1035  $valuetoshow .= ($valuetoshow ? ' + ' : '').'<input type="hidden" name="password" value="'.dol_escape_htmltag($ldap_pass).'">'; // Dolibarr password is preffiled with LDAP known password
1036  $valuetoshow .= preg_replace('/./i', '*', $ldap_pass);
1037  } else {
1038  // We do not use a field password but a field text to show new password to use.
1039  $valuetoshow .= ($valuetoshow ? ' + '.$langs->trans("DolibarrPassword") : '').'<input class="minwidth300 maxwidth400 widthcentpercentminusx" maxsize="32" type="text" id="password" name="password" value="'.dol_escape_htmltag($password).'" autocomplete="new-password">';
1040  if (!empty($conf->use_javascript_ajax)) {
1041  $valuetoshow .= '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_password" class="linkobject"');
1042  }
1043  }
1044  }
1045 
1046  // Other form for user password
1047  $parameters = array('valuetoshow' => $valuetoshow, 'password' => $password);
1048  $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1049  if ($reshook > 0) {
1050  $valuetoshow = $hookmanager->resPrint; // to replace
1051  } else {
1052  $valuetoshow .= $hookmanager->resPrint; // to add
1053  }
1054 
1055  print $valuetoshow;
1056  print '</td></tr>';
1057 
1058  if (!empty($conf->api->enabled)) {
1059  // API key
1060  //$generated_password = getRandomPassword(false);
1061  print '<tr><td>'.$langs->trans("ApiKey").'</td>';
1062  print '<td>';
1063  print '<input class="minwidth300 maxwidth400 widthcentpercentminusx" maxsize="32" type="text" id="api_key" name="api_key" value="'.GETPOST('api_key', 'alphanohtml').'" autocomplete="off">';
1064  if (!empty($conf->use_javascript_ajax)) {
1065  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
1066  }
1067  print '</td></tr>';
1068  } else {
1069  // PARTIAL WORKAROUND
1070  $generated_fake_api_key = getRandomPassword(false);
1071  print '<input type="hidden" name="api_key" value="'.$generated_fake_api_key.'">';
1072  }
1073 
1074 
1075  print '</table><hr><table class="border centpercent">';
1076 
1077 
1078  // Address
1079  print '<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
1080  print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1081  print $object->address;
1082  print '</textarea></td></tr>';
1083 
1084  // Zip
1085  print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
1086  print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
1087  print '</td></tr>';
1088 
1089  // Town
1090  print '<tr><td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
1091  print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
1092  print '</td></tr>';
1093 
1094  // Country
1095  print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
1096  print img_picto('', 'country', 'class="pictofixedwidth"');
1097  print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id));
1098  if ($user->admin) {
1099  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1100  }
1101  print '</td></tr>';
1102 
1103  // State
1104  if (empty($conf->global->USER_DISABLE_STATE)) {
1105  print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
1106  print img_picto('', 'state', 'class="pictofixedwidth"');
1107  print $formcompany->select_state($object->state_id, $object->country_code, 'state_id');
1108  print '</td></tr>';
1109  }
1110 
1111  // Tel
1112  print '<tr><td>'.$langs->trans("PhonePro").'</td>';
1113  print '<td>';
1114  print img_picto('', 'object_phoning', 'class="pictofixedwidth"');
1115  if (!empty($ldap_phone)) {
1116  print '<input type="hidden" name="office_phone" value="'.dol_escape_htmltag($ldap_phone).'">';
1117  print $ldap_phone;
1118  } else {
1119  print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_phone" value="'.dol_escape_htmltag(GETPOST('office_phone', 'alphanohtml')).'">';
1120  }
1121  print '</td></tr>';
1122 
1123  // Tel portable
1124  print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
1125  print '<td>';
1126  print img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"');
1127  if (!empty($ldap_mobile)) {
1128  print '<input type="hidden" name="user_mobile" value="'.dol_escape_htmltag($ldap_mobile).'">';
1129  print $ldap_mobile;
1130  } else {
1131  print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="user_mobile" value="'.dol_escape_htmltag(GETPOST('user_mobile', 'alphanohtml')).'">';
1132  }
1133  print '</td></tr>';
1134 
1135  // Fax
1136  print '<tr><td>'.$langs->trans("Fax").'</td>';
1137  print '<td>';
1138  print img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"');
1139  if (!empty($ldap_fax)) {
1140  print '<input type="hidden" name="office_fax" value="'.dol_escape_htmltag($ldap_fax).'">';
1141  print $ldap_fax;
1142  } else {
1143  print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_fax" value="'.dol_escape_htmltag(GETPOST('office_fax', 'alphanohtml')).'">';
1144  }
1145  print '</td></tr>';
1146 
1147  // EMail
1148  print '<tr><td'.(!empty($conf->global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.$langs->trans("EMail").'</td>';
1149  print '<td>';
1150  print img_picto('', 'object_email', 'class="pictofixedwidth"');
1151  if (!empty($ldap_mail)) {
1152  print '<input type="hidden" name="email" value="'.dol_escape_htmltag($ldap_mail).'">';
1153  print $ldap_mail;
1154  } else {
1155  print '<input type="text" name="email" class="maxwidth500 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('email', 'alphanohtml')).'">';
1156  }
1157  print '</td></tr>';
1158 
1159  // Social networks
1160  if (isModEnabled('socialnetworks')) {
1161  foreach ($socialnetworks as $key => $value) {
1162  if ($value['active']) {
1163  print '<tr><td>'.$langs->trans($value['label']).'</td>';
1164  print '<td>';
1165  if (!empty($value['icon'])) {
1166  print '<span class="fa '.$value['icon'].' pictofixedwidth"></span>';
1167  }
1168  if (!empty($ldap_social[$key])) {
1169  print '<input type="hidden" name="'.$key.'" value="'.$ldap_social[$key].'">';
1170  print $ldap_social[$key];
1171  } else {
1172  print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="'.$key.'" value="'.GETPOST($key, 'alphanohtml').'">';
1173  }
1174  print '</td></tr>';
1175  } else {
1176  // if social network is not active but value exist we do not want to loose it
1177  if (!empty($ldap_social[$key])) {
1178  print '<input type="hidden" name="'.$key.'" value="'.$ldap_social[$key].'">';
1179  } else {
1180  print '<input type="hidden" name="'.$key.'" value="'.GETPOST($key, 'alphanohtml').'">';
1181  }
1182  }
1183  }
1184  }
1185 
1186  // Accountancy code
1187  if (isModEnabled('accounting')) {
1188  print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
1189  print '<td>';
1190  print '<input type="text" class="maxwidthonsmartphone" name="accountancy_code" value="'.dol_escape_htmltag(GETPOST('accountancy_code', 'alphanohtml')).'">';
1191  print '</td></tr>';
1192  }
1193 
1194  // User color
1195  if (isModEnabled('agenda')) {
1196  print '<tr><td>'.$langs->trans("ColorUser").'</td>';
1197  print '<td>';
1198  print $formother->selectColor(GETPOSTISSET('color') ?GETPOST('color', 'alphanohtml') : $object->color, 'color', null, 1, '', 'hideifnotset');
1199  print '</td></tr>';
1200  }
1201 
1202  // Categories
1203  if (isModEnabled('categorie') && $user->hasRight("categorie", "read")) {
1204  print '<tr><td>'.$form->editfieldkey('Categories', 'usercats', '', $object, 0).'</td><td>';
1205  $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1);
1206  print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), 0, 0, 'maxwdith300 widthcentpercentminusx', 0, '90%');
1207  print "</td></tr>";
1208  }
1209 
1210  // Default language
1211  if (getDolGlobalInt('MAIN_MULTILANGS')) {
1212  print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0, 'string', '', 0, 0, 'id', $langs->trans("WarningNotLangOfInterface", $langs->transnoentitiesnoconv("UserGUISetup"))).'</td>';
1213  print '<td class="maxwidthonsmartphone">'."\n";
1214  print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->lang ? $object->lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth300 widthcentpercentminusx');
1215  print '</td>';
1216  print '</tr>';
1217  }
1218 
1219  // Multicompany
1220  if (isModEnabled('multicompany') && is_object($mc)) {
1221  // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
1222  if (!method_exists($mc, 'formObjectOptions')) {
1223  if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { // condition must be same for create and edit mode
1224  print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
1225  print "<td>".$mc->select_entities($conf->entity);
1226  print "</td></tr>\n";
1227  } else {
1228  print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
1229  }
1230  }
1231  }
1232 
1233  // Other attributes
1234  $parameters = array();
1235  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
1236 
1237  // Signature
1238  print '<tr><td class="tdtop">'.$langs->trans("Signature").'</td>';
1239  print '<td class="wordbreak">';
1240  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1241 
1242  $doleditor = new DolEditor('signature', GETPOST('signature', 'restricthtml'), '', 138, 'dolibarr_notes', 'In', true, $acceptlocallinktomedia, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%');
1243  print $doleditor->Create(1);
1244  print '</td></tr>';
1245 
1246  // Note private
1247  print '<tr><td class="tdtop">';
1248  print $langs->trans("NotePublic");
1249  print '</td><td>';
1250  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1251  $doleditor = new DolEditor('note_public', GETPOSTISSET('note_public') ? GETPOST('note_public', 'restricthtml') : '', '', 100, 'dolibarr_notes', '', false, true, getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC'), ROWS_3, '90%');
1252  $doleditor->Create();
1253  print "</td></tr>\n";
1254 
1255  // Note private
1256  print '<tr><td class="tdtop">';
1257  print $langs->trans("NotePrivate");
1258  print '</td><td>';
1259  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1260  $doleditor = new DolEditor('note_private', GETPOSTISSET('note_private') ? GETPOST('note_private', 'restricthtml') : '', '', 100, 'dolibarr_notes', '', false, true, getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_3, '90%');
1261  $doleditor->Create();
1262  print "</td></tr>\n";
1263 
1264  print '</table><hr><table class="border centpercent">';
1265 
1266 
1267  // TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
1268 
1269  // Default warehouse
1270  if (isModEnabled('stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1271  print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
1272  print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1);
1273  print '</td></tr>';
1274  }
1275 
1276  // Position/Job
1277  print '<tr><td class="titlefieldcreate">'.$langs->trans("PostOrFunction").'</td>';
1278  print '<td>';
1279  print '<input class="maxwidth200 maxwidth150onsmartphone" type="text" name="job" value="'.dol_escape_htmltag(GETPOST('job', 'alphanohtml')).'">';
1280  print '</td></tr>';
1281 
1282  if ((!empty($conf->salaries->enabled) && $user->hasRight("salaries", "read") && in_array($id, $childids))
1283  || (!empty($conf->salaries->enabled) && $user->hasRight("salaries", "readall"))
1284  || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) {
1285  $langs->load("salaries");
1286 
1287  // THM
1288  print '<tr><td>';
1289  $text = $langs->trans("THM");
1290  print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
1291  print '</td>';
1292  print '<td>';
1293  print '<input size="8" type="text" name="thm" value="'.dol_escape_htmltag(GETPOST('thm')).'"> '.$langs->getCurrencySymbol($conf->currency);
1294  print '</td>';
1295  print "</tr>\n";
1296 
1297  // TJM
1298  print '<tr><td>';
1299  $text = $langs->trans("TJM");
1300  print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm');
1301  print '</td>';
1302  print '<td>';
1303  print '<input size="8" type="text" name="tjm" value="'.dol_escape_htmltag(GETPOST('tjm')).'"> '.$langs->getCurrencySymbol($conf->currency);
1304  print '</td>';
1305  print "</tr>\n";
1306 
1307  // Salary
1308  print '<tr><td>'.$langs->trans("Salary").'</td>';
1309  print '<td>';
1310  print img_picto('', 'salary', 'class="pictofixedwidth paddingright"').'<input size="8" type="text" name="salary" value="'.dol_escape_htmltag(GETPOST('salary')).'"> '.$langs->getCurrencySymbol($conf->currency);
1311  print '</td>';
1312  print "</tr>\n";
1313  }
1314 
1315  // Weeklyhours
1316  print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
1317  print '<td>';
1318  print '<input size="8" type="text" name="weeklyhours" value="'.dol_escape_htmltag(GETPOST('weeklyhours')).'">';
1319  print '</td>';
1320  print "</tr>\n";
1321 
1322  // Date employment
1323  print '<tr><td>'.$langs->trans("DateOfEmployment").'</td>';
1324  print '<td>';
1325  print $form->selectDate($dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 1);
1326 
1327  print ' - ';
1328 
1329  print $form->selectDate($dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0);
1330  print '</td>';
1331  print "</tr>\n";
1332 
1333  // Date birth
1334  print '<tr><td>'.$langs->trans("DateOfBirth").'</td>';
1335  print '<td>';
1336  print $form->selectDate($dateofbirth, 'dateofbirth', 0, 0, 1, 'createuser', 1, 0, 0, '', 0, '', '', 1, '', '', 'tzserver');
1337  print '</td>';
1338  print "</tr>\n";
1339 
1340  print "</table>\n";
1341 
1342  print dol_get_fiche_end();
1343 
1344  print $form->buttonsSaveCancel("CreateUser");
1345 
1346  print "</form>";
1347 } else {
1348  // View and edit mode
1349  if ($id > 0) {
1350  $res = $object->fetch($id, '', '', 1);
1351  if ($res < 0) {
1352  dol_print_error($db, $object->error);
1353  exit;
1354  }
1355  $res = $object->fetch_optionals();
1356 
1357  // Check if user has rights
1358  if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1359  $object->getrights();
1360  if (empty($object->nb_rights) && $object->statut != 0 && empty($object->admin)) {
1361  setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings');
1362  }
1363  }
1364 
1365  // Connexion ldap
1366  // pour recuperer passDoNotExpire et userChangePassNextLogon
1367  if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) {
1368  $ldap = new Ldap();
1369  $result = $ldap->connect_bind();
1370  if ($result > 0) {
1371  $userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$ldap->getUserIdentifier().'='.$object->login.'))';
1372  $entries = $ldap->fetch($object->login, $userSearchFilter);
1373  if (!$entries) {
1374  setEventMessages($ldap->error, $ldap->errors, 'errors');
1375  }
1376 
1377  $passDoNotExpire = 0;
1378  $userChangePassNextLogon = 0;
1379  $userDisabled = 0;
1380  $statutUACF = '';
1381 
1382  // Check options of user account
1383  if (count($ldap->uacf) > 0) {
1384  foreach ($ldap->uacf as $key => $statut) {
1385  if ($key == 65536) {
1386  $passDoNotExpire = 1;
1387  $statutUACF = $statut;
1388  }
1389  }
1390  } else {
1391  $userDisabled = 1;
1392  $statutUACF = "ACCOUNTDISABLE";
1393  }
1394 
1395  if ($ldap->pwdlastset == 0) {
1396  $userChangePassNextLogon = 1;
1397  }
1398  }
1399  }
1400 
1401  // Show tabs
1402  if ($mode == 'employee') { // For HRM module development
1403  $title = $langs->trans("Employee");
1404  $linkback = '<a href="'.DOL_URL_ROOT.'/hrm/employee/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1405  } else {
1406  $title = $langs->trans("User");
1407  $linkback = '';
1408 
1409  if ($user->hasRight("user", "user", "read") || $user->admin) {
1410  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1411  }
1412  }
1413 
1414  $head = user_prepare_head($object);
1415 
1416  /*
1417  * Confirmation reinitialisation mot de passe
1418  */
1419  if ($action == 'password') {
1420  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("ReinitPassword"), $langs->trans("ConfirmReinitPassword", $object->login), "confirm_password", '', 0, 1);
1421  }
1422 
1423  /*
1424  * Confirmation envoi mot de passe
1425  */
1426  if ($action == 'passwordsend') {
1427  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("SendNewPassword"), $langs->trans("ConfirmSendNewPassword", $object->login), "confirm_passwordsend", '', 0, 1);
1428  }
1429 
1430  /*
1431  * Confirm deactivation
1432  */
1433  if ($action == 'disable') {
1434  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DisableAUser"), $langs->trans("ConfirmDisableUser", $object->login), "confirm_disable", '', 0, 1);
1435  }
1436 
1437  /*
1438  * Confirm activation
1439  */
1440  if ($action == 'enable') {
1441  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("EnableAUser"), $langs->trans("ConfirmEnableUser", $object->login), "confirm_enable", '', 0, 1);
1442  }
1443 
1444  /*
1445  * Confirmation suppression
1446  */
1447  if ($action == 'delete') {
1448  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DeleteAUser"), $langs->trans("ConfirmDeleteUser", $object->login), "confirm_delete", '', 0, 1);
1449  }
1450 
1451  /*
1452  * Fiche en mode visu
1453  */
1454  if ($action != 'edit') {
1455  print dol_get_fiche_head($head, 'user', $title, -1, 'user');
1456 
1457  $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'" class="refid">';
1458  $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
1459  $morehtmlref .= '</a>';
1460 
1461  dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
1462 
1463  print '<div class="fichecenter">';
1464  print '<div class="fichehalfleft">';
1465 
1466  print '<div class="underbanner clearboth"></div>';
1467  print '<table class="border tableforfield centpercent">';
1468 
1469  // Login
1470  print '<tr><td class="titlefieldmiddle">'.$langs->trans("Login").'</td>';
1471  if (!empty($object->ldap_sid) && $object->statut == 0) {
1472  print '<td class="error">';
1473  print $langs->trans("LoginAccountDisableInDolibarr");
1474  print '</td>';
1475  } else {
1476  print '<td>';
1477  $addadmin = '';
1478  if (property_exists($object, 'admin')) {
1479  if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
1480  $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
1481  } elseif (!empty($object->admin)) {
1482  $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
1483  }
1484  }
1485  print showValueWithClipboardCPButton($object->login).$addadmin;
1486  print '</td>';
1487  }
1488  print '</tr>'."\n";
1489 
1490  // Type
1491  print '<tr><td>';
1492  $text = $langs->trans("Type");
1493  print $form->textwithpicto($text, $langs->trans("InternalExternalDesc"));
1494  print '</td><td>';
1495  $type = $langs->trans("Internal");
1496  if ($object->socid > 0) {
1497  $type = $langs->trans("External");
1498  }
1499  print '<span class="badgeneutral">';
1500  print $type;
1501  if ($object->ldap_sid) {
1502  print ' ('.$langs->trans("DomainUser").')';
1503  }
1504  print '</span>';
1505  print '</td></tr>'."\n";
1506 
1507  // Ldap sid
1508  if ($object->ldap_sid) {
1509  print '<tr><td>'.$langs->trans("Type").'</td><td>';
1510  print $langs->trans("DomainUser", $ldap->domainFQDN);
1511  print '</td></tr>'."\n";
1512  }
1513 
1514  // Employee
1515  print '<tr><td>'.$langs->trans("Employee").'</td><td>';
1516  print '<input type="checkbox" disabled name="employee" value="1"'.($object->employee ? ' checked="checked"' : '').'>';
1517  //print yn($object->employee);
1518  print '</td></tr>'."\n";
1519 
1520  // TODO This is also available into the tab RH
1521 
1522  // Hierarchy
1523  print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>';
1524  print '<td>';
1525  if (empty($object->fk_user)) {
1526  print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
1527  } else {
1528  $huser = new User($db);
1529  if ($object->fk_user > 0) {
1530  $huser->fetch($object->fk_user);
1531  print $huser->getNomUrl(1);
1532  } else {
1533  print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
1534  }
1535  }
1536  print '</td>';
1537  print "</tr>\n";
1538 
1539  // Expense report validator
1540  if (isModEnabled('expensereport')) {
1541  print '<tr><td>';
1542  $text = $langs->trans("ForceUserExpenseValidator");
1543  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
1544  print '</td>';
1545  print '<td>';
1546  if (!empty($object->fk_user_expense_validator)) {
1547  $evuser = new User($db);
1548  $evuser->fetch($object->fk_user_expense_validator);
1549  print $evuser->getNomUrl(1);
1550  }
1551  print '</td>';
1552  print "</tr>\n";
1553  }
1554 
1555  // Holiday request validator
1556  if (isModEnabled('holiday')) {
1557  print '<tr><td>';
1558  $text = $langs->trans("ForceUserHolidayValidator");
1559  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
1560  print '</td>';
1561  print '<td>';
1562  if (!empty($object->fk_user_holiday_validator)) {
1563  $hvuser = new User($db);
1564  $hvuser->fetch($object->fk_user_holiday_validator);
1565  print $hvuser->getNomUrl(1);
1566  }
1567  print '</td>';
1568  print "</tr>\n";
1569  }
1570 
1571  // Position/Job
1572  print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
1573  print '<td>'.dol_escape_htmltag($object->job).'</td>';
1574  print '</tr>'."\n";
1575 
1576  // Weeklyhours
1577  print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
1578  print '<td>';
1579  print price2num($object->weeklyhours);
1580  print '</td>';
1581  print "</tr>\n";
1582 
1583  // Sensitive salary/value information
1584  if ((empty($user->socid) && in_array($id, $childids)) // A user can always see salary/value information for its subordinates
1585  || (!empty($conf->salaries->enabled) && $user->hasRight("salaries", "readall"))
1586  || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) {
1587  $langs->load("salaries");
1588 
1589  // Salary
1590  print '<tr><td>'.$langs->trans("Salary").'</td>';
1591  print '<td>';
1592  print ($object->salary != '' ? img_picto('', 'salary', 'class="pictofixedwidth paddingright"').'<span class="amount">'.price($object->salary, '', $langs, 1, -1, -1, $conf->currency) : '').'</span>';
1593  print '</td>';
1594  print "</tr>\n";
1595 
1596  // THM
1597  print '<tr><td>';
1598  $text = $langs->trans("THM");
1599  print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
1600  print '</td>';
1601  print '<td>';
1602  print ($object->thm != '' ?price($object->thm, '', $langs, 1, -1, -1, $conf->currency) : '');
1603  print '</td>';
1604  print "</tr>\n";
1605 
1606  // TJM
1607  print '<tr><td>';
1608  $text = $langs->trans("TJM");
1609  print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm');
1610  print '</td>';
1611  print '<td>';
1612  print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : '');
1613  print '</td>';
1614  print "</tr>\n";
1615  }
1616 
1617  // Date employment
1618  print '<tr><td>'.$langs->trans("DateOfEmployment").'</td>';
1619  print '<td>';
1620  if ($object->dateemployment) {
1621  print '<span class="opacitymedium">'.$langs->trans("FromDate").'</span> ';
1622  print dol_print_date($object->dateemployment, 'day');
1623  }
1624  if ($object->dateemploymentend) {
1625  print '<span class="opacitymedium"> - '.$langs->trans("To").'</span> ';
1626  print dol_print_date($object->dateemploymentend, 'day');
1627  }
1628  print '</td>';
1629  print "</tr>\n";
1630 
1631  // Date of birth
1632  print '<tr><td>'.$langs->trans("DateOfBirth").'</td>';
1633  print '<td>';
1634  print dol_print_date($object->birth, 'day', 'tzserver');
1635  print '</td>';
1636  print "</tr>\n";
1637 
1638  // Default warehouse
1639  if (isModEnabled('stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1640  require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1641  print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
1642  if ($object->fk_warehouse > 0) {
1643  $warehousestatic = new Entrepot($db);
1644  $warehousestatic->fetch($object->fk_warehouse);
1645  print $warehousestatic->getNomUrl(1);
1646  }
1647  print '</td></tr>';
1648  }
1649 
1650  print '</table>';
1651 
1652  print '</div>';
1653  print '<div class="fichehalfright">';
1654 
1655  print '<div class="underbanner clearboth"></div>';
1656 
1657  print '<table class="border tableforfield centpercent">';
1658 
1659  // Color user
1660  if (isModEnabled('agenda')) {
1661  print '<tr><td class="titlefield">'.$langs->trans("ColorUser").'</td>';
1662  print '<td>';
1663  print $formother->showColor($object->color, '');
1664  print '</td>';
1665  print "</tr>\n";
1666  }
1667 
1668  // Categories
1669  if (isModEnabled('categorie') && $user->hasRight("categorie", "read")) {
1670  print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td>';
1671  print '<td colspan="3">';
1672  print $form->showCategories($object->id, Categorie::TYPE_USER, 1);
1673  print '</td></tr>';
1674  }
1675 
1676  // Default language
1677  if (getDolGlobalInt('MAIN_MULTILANGS')) {
1678  $langs->load("languages");
1679  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1680  print '<tr><td class="titlefield">';
1681  print $form->textwithpicto($langs->trans("DefaultLang"), $langs->trans("WarningNotLangOfInterface", $langs->transnoentitiesnoconv("UserGUISetup")));
1682  print '</td><td>';
1683  //$s=picto_from_langcode($object->default_lang);
1684  //print ($s?$s.' ':'');
1685  $labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : '');
1686  print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"');
1687  print $labellang;
1688  print '</td></tr>';
1689  }
1690 
1691  if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
1692  print '<tr><td>'.$langs->trans("OpenIDURL").'</td>';
1693  print '<td>'.$object->openid.'</td>';
1694  print "</tr>\n";
1695  }
1696 
1697  // Multicompany
1698  if (isModEnabled('multicompany') && is_object($mc)) {
1699  // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
1700  if (!method_exists($mc, 'formObjectOptions')) {
1701  if (isModEnabled('multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
1702  print '<tr><td>'.$langs->trans("Entity").'</td><td>';
1703  if (empty($object->entity)) {
1704  print $langs->trans("AllEntities");
1705  } else {
1706  $mc->getInfo($object->entity);
1707  print $mc->label;
1708  }
1709  print "</td></tr>\n";
1710  }
1711  }
1712  }
1713 
1714  // Other attributes
1715  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1716 
1717  // Company / Contact
1718  if (isModEnabled("societe")) {
1719  print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>';
1720  print '<td>';
1721  $s = '';
1722  if (isset($object->socid) && $object->socid > 0) {
1723  $societe = new Societe($db);
1724  $societe->fetch($object->socid);
1725  if ($societe->id > 0) {
1726  $s .= $societe->getNomUrl(1, '');
1727  }
1728  } else {
1729  $s .= '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ThisUserIsNot").'</span>';
1730  }
1731  if (!empty($object->contact_id)) {
1732  $contact = new Contact($db);
1733  $contact->fetch($object->contact_id);
1734  if ($contact->id > 0) {
1735  if ($object->socid > 0 && $s) {
1736  $s .= ' / ';
1737  } else {
1738  $s .= '<br>';
1739  }
1740  $s .= $contact->getNomUrl(1, '');
1741  }
1742  }
1743  print $s;
1744  print '</td>';
1745  print '</tr>'."\n";
1746  }
1747 
1748  // Module Adherent
1749  if (isModEnabled('adherent')) {
1750  $langs->load("members");
1751  print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
1752  print '<td>';
1753  if ($object->fk_member) {
1754  $adh = new Adherent($db);
1755  $adh->fetch($object->fk_member);
1756  $adh->ref = $adh->getFullname($langs); // Force to show login instead of id
1757  print $adh->getNomUrl(-1);
1758  } else {
1759  print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("UserNotLinkedToMember").'</span>';
1760  }
1761  print '</td>';
1762  print '</tr>'."\n";
1763  }
1764 
1765  // Signature
1766  print '<tr><td class="tdtop">'.$langs->trans('Signature').'</td><td class="wordbreak">';
1767  print dol_htmlentitiesbr($object->signature);
1768  print "</td></tr>\n";
1769 
1770  print "</table>\n";
1771 
1772 
1773  // Credentials
1774  print '<br>';
1775  print '<div class="div-table-responsive-no-min">';
1776  print '<table class="border tableforfield centpercent">';
1777  print '<tr class="liste_titre"><td class="liste_titre">';
1778  print img_picto('', 'security', 'class="paddingleft pictofixedwidth"').$langs->trans("Credentials");
1779  print '</td>';
1780  print '<td class="liste_titre"></td>';
1781  print '</tr>';
1782 
1783  // Date login validity
1784  print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("RangeOfLoginValidity").'</td>';
1785  print '<td>';
1786  if ($object->datestartvalidity) {
1787  print '<span class="opacitymedium">'.$langs->trans("FromDate").'</span> ';
1788  print dol_print_date($object->datestartvalidity, 'day');
1789  }
1790  if ($object->dateendvalidity) {
1791  print '<span class="opacitymedium"> - '.$langs->trans("To").'</span> ';
1792  print dol_print_date($object->dateendvalidity, 'day');
1793  }
1794  print '</td>';
1795  print "</tr>\n";
1796 
1797  // Password
1798  $valuetoshow = '';
1799  if (preg_match('/ldap/', $dolibarr_main_authentication)) {
1800  if (!empty($object->ldap_sid)) {
1801  if ($passDoNotExpire) {
1802  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("LdapUacf_".$statutUACF);
1803  } elseif ($userChangePassNextLogon) {
1804  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<span class="warning">'.$langs->trans("UserMustChangePassNextLogon", $ldap->domainFQDN).'</span>';
1805  } elseif ($userDisabled) {
1806  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<span class="warning">'.$langs->trans("LdapUacf_".$statutUACF, $ldap->domainFQDN).'</span>';
1807  } else {
1808  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP");
1809  }
1810  } else {
1811  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP");
1812  }
1813  }
1814  if (preg_match('/http/', $dolibarr_main_authentication)) {
1815  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("HTTPBasicPassword");
1816  }
1817  /*
1818  if (preg_match('/dolibarr/', $dolibarr_main_authentication)) {
1819  if ($object->pass) {
1820  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '');
1821  $valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1822  } else {
1823  if ($user->admin && $user->id == $object->id) {
1824  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '');
1825  $valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1826  $valuetoshow .= '<!-- Crypted into '.$object->pass_indatabase_crypted.' -->';
1827  } else {
1828  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '');
1829  $valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1830  }
1831  }
1832  }
1833  */
1834 
1835  // Other form for user password
1836  $parameters = array('valuetoshow' => $valuetoshow);
1837  $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1838  if ($reshook > 0) {
1839  $valuetoshow = $hookmanager->resPrint; // to replace
1840  } else {
1841  $valuetoshow .= $hookmanager->resPrint; // to add
1842  }
1843 
1844  if (dol_string_nohtmltag($valuetoshow)) { // If there is a real visible content to show
1845  print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("Password").'</td>';
1846  print '<td class="wordbreak">';
1847  print $valuetoshow;
1848  print "</td>";
1849  print '</tr>'."\n";
1850  }
1851 
1852  // API key
1853  if (!empty($conf->api->enabled) && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) {
1854  print '<tr class="nooddeven"><td>'.$langs->trans("ApiKey").'</td>';
1855  print '<td>';
1856  if (!empty($object->api_key)) {
1857  print '<span class="opacitymedium">';
1858  print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste
1859  print '</span>';
1860  }
1861  print '</td></tr>';
1862  }
1863 
1864  print '<tr class="nooddeven"><td>'.$langs->trans("LastConnexion").'</td>';
1865  print '<td>';
1866  if ($object->datepreviouslogin) {
1867  print dol_print_date($object->datepreviouslogin, "dayhour", "tzuserrel").' <span class="opacitymedium">('.$langs->trans("Previous").')</span>, ';
1868  }
1869  if ($object->datelastlogin) {
1870  print dol_print_date($object->datelastlogin, "dayhour", "tzuserrel").' <span class="opacitymedium">('.$langs->trans("Currently").')</span>';
1871  }
1872  print '</td>';
1873  print "</tr>\n";
1874 
1875  print '</table>';
1876  print '</div>';
1877 
1878  print '</div>';
1879 
1880  print '</div>';
1881  print '<div style="clear:both"></div>';
1882 
1883 
1884  print dol_get_fiche_end();
1885 
1886 
1887  /*
1888  * Buttons actions
1889  */
1890  print '<div class="tabsAction">';
1891 
1892  $parameters = array();
1893  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1894  if (empty($reshook)) {
1895  if (empty($user->socid)) {
1896  $canSendMail = false;
1897  $params = array(
1898  'attr' => array(
1899  'title' => '',
1900  'class' => 'classfortooltip'
1901  )
1902  );
1903  if (!empty($object->email)) {
1904  $langs->load("mails");
1905  $canSendMail = true;
1906  } else {
1907  $langs->load("mails");
1908  $params['attr']['title'] = $langs->trans('NoEMail');
1909  }
1910  print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params);
1911  }
1912 
1913  if ($caneditfield && (!isModEnabled('multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1914  $params = array(
1915  'attr' => array(
1916  'title' => '',
1917  'class' => 'classfortooltip'
1918  )
1919  );
1920  if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
1921  $params['attr']['title'] = $langs->trans('DisabledInMonoUserMode');
1922  print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1923  } else {
1924  print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit&token='.newToken(), '', true, $params);
1925  }
1926  } elseif ($caneditpassword && !$object->ldap_sid &&
1927  (!isModEnabled('multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1928  $params = array(
1929  'attr' => array(
1930  'title' => '',
1931  'class' => 'classfortooltip'
1932  )
1933  );
1934  print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit', '', true, $params);
1935  }
1936 
1937  // Si on a un gestionnaire de generation de mot de passe actif
1938  $params = array(
1939  'attr' => array(
1940  'title' => '',
1941  'class' => 'classfortooltip'
1942  )
1943  );
1944  if ($conf->global->USER_PASSWORD_GENERATED != 'none') {
1945  if ($object->statut == 0) {
1946  $params['attr']['title'] = $langs->trans('UserDisabled');
1947  print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1948  } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
1949  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1950  print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=password&token='.newToken(), '', true, $params);
1951  }
1952 
1953  if ($object->statut == 0) {
1954  $params['attr']['title'] = $langs->trans('UserDisabled');
1955  print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1956  } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
1957  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1958  if ($object->email) {
1959  print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=passwordsend&token='.newToken(), '', true, $params);
1960  } else {
1961  $params['attr']['title'] = $langs->trans('NoEMail');
1962  print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1963  }
1964  }
1965  }
1966 
1967  // Enable user
1968  $params = array(
1969  'attr' => array(
1970  'title' => '',
1971  'class' => 'classfortooltip'
1972  )
1973  );
1974  if ($user->id <> $id && $candisableuser && $object->statut == 0 &&
1975  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1976  print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=enable&token='.newToken(), '', true, $params);
1977  }
1978  // Disable user
1979  if ($user->id <> $id && $candisableuser && $object->statut == 1 &&
1980  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1981  print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=disable&token='.newToken(), '', true, $params);
1982  } else {
1983  if ($user->id == $id) {
1984  $params['attr']['title'] = $langs->trans('CantDisableYourself');
1985  print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1986  }
1987  }
1988  // Delete
1989  if ($user->id <> $id && $candisableuser &&
1990  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1991  if ($user->admin || !$object->admin) { // If user edited is admin, delete is possible on for an admin
1992  print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', true, $params);
1993  } else {
1994  $params['attr']['title'] = $langs->trans('MustBeAdminToDeleteOtherAdmin');
1995  print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', false, $params);
1996  }
1997  }
1998  }
1999 
2000  print "</div>\n";
2001 
2002 
2003 
2004  // Select mail models is same action as presend
2005  if (GETPOST('modelselected')) {
2006  $action = 'presend';
2007  }
2008 
2009  // Presend form
2010  $modelmail = 'user';
2011  $defaulttopic = 'Information';
2012  $diroutput = $conf->user->dir_output;
2013  $trackid = 'use'.$object->id;
2014 
2015  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
2016 
2017  if ($action != 'presend' && $action != 'send') {
2018  /*
2019  * List of groups of user
2020  */
2021 
2022  if ($canreadgroup) {
2023  print '<!-- Group section -->'."\n";
2024 
2025  print load_fiche_titre($langs->trans("ListOfGroupsForUser"), '', '');
2026 
2027  // On selectionne les groupes auquel fait parti le user
2028  $exclude = array();
2029 
2030  $usergroup = new UserGroup($db);
2031  $groupslist = $usergroup->listGroupsForUser($object->id, false);
2032 
2033  if (!empty($groupslist)) {
2034  foreach ($groupslist as $groupforuser) {
2035  $exclude[] = $groupforuser->id;
2036  }
2037  }
2038 
2039  // Other form for add user to group
2040  $parameters = array('caneditgroup' => $caneditgroup, 'groupslist' => $groupslist, 'exclude' => $exclude);
2041  $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2042  print $hookmanager->resPrint;
2043 
2044  if (empty($reshook)) {
2045  if ($caneditgroup) {
2046  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'."\n";
2047  print '<input type="hidden" name="token" value="'.newToken().'" />';
2048  print '<input type="hidden" name="action" value="addgroup" />';
2049  print '<input type="hidden" name="page_y" value="" />';
2050  }
2051 
2052  print '<table class="noborder centpercent">'."\n";
2053  print '<tr class="liste_titre"><th class="liste_titre">'.$langs->trans("Groups").'</th>'."\n";
2054  print '<th class="liste_titre right">';
2055  if ($caneditgroup) {
2056  print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
2057  print ' &nbsp; ';
2058  print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
2059  print '<input type="submit" class="button buttongen button-add reposition" value="'.$langs->trans("Add").'" />';
2060  }
2061  print '</th></tr>'."\n";
2062 
2063  // List of groups of user
2064  if (!empty($groupslist)) {
2065  foreach ($groupslist as $group) {
2066  print '<tr class="oddeven">';
2067  print '<td>';
2068  if ($caneditgroup) {
2069  print $group->getNomUrl(1);
2070  } else {
2071  print img_object($langs->trans("ShowGroup"), "group").' '.$group->name;
2072  }
2073  print '</td>';
2074  print '<td class="right">';
2075  if ($caneditgroup) {
2076  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&token='.newToken().'&group='.((int) $group->id).'">';
2077  print img_picto($langs->trans("RemoveFromGroup"), 'unlink');
2078  print '</a>';
2079  } else {
2080  print "&nbsp;";
2081  }
2082  print "</td></tr>\n";
2083  }
2084  } else {
2085  print '<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
2086  }
2087 
2088  print "</table>";
2089 
2090  if ($caneditgroup) {
2091  print '</form>';
2092  }
2093  print "<br>";
2094  }
2095  }
2096  }
2097  }
2098 
2099  /*
2100  * Card in edit mode
2101  */
2102  if ($action == 'edit' && ($canedituser || $caneditpassword)) {
2103  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST" name="updateuser" enctype="multipart/form-data">';
2104  print '<input type="hidden" name="token" value="'.newToken().'">';
2105  print '<input type="hidden" name="action" value="update">';
2106  print '<input type="hidden" name="entity" value="'.$object->entity.'">';
2107 
2108  print dol_get_fiche_head($head, 'user', $title, 0, 'user');
2109 
2110  print '<table class="border centpercent">';
2111 
2112  // Ref/ID
2113  if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2114  print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td>';
2115  print '<td>';
2116  print $object->id;
2117  print '</td>';
2118  print '</tr>';
2119  }
2120 
2121  // Civility
2122  print '<tr><td class="titlefieldcreate"><label for="civility_code">'.$langs->trans("UserTitle").'</label></td><td>';
2123  if ($caneditfield && !$object->ldap_sid) {
2124  print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'aZ09') : $object->civility_code, 'civility_code');
2125  } elseif ($object->civility_code) {
2126  print $langs->trans("Civility".$object->civility_code);
2127  }
2128  print '</td></tr>';
2129 
2130  // Lastname
2131  print "<tr>";
2132  print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Lastname").'</td>';
2133  print '<td>';
2134  if ($caneditfield && !$object->ldap_sid) {
2135  print '<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.'">';
2136  } else {
2137  print '<input type="hidden" name="lastname" value="'.$object->lastname.'">';
2138  print $object->lastname;
2139  }
2140  print '</td>';
2141  print '</tr>';
2142 
2143  // Firstname
2144  print '<tr><td>'.$langs->trans("Firstname").'</td>';
2145  print '<td>';
2146  if ($caneditfield && !$object->ldap_sid) {
2147  print '<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.'">';
2148  } else {
2149  print '<input type="hidden" name="firstname" value="'.$object->firstname.'">';
2150  print $object->firstname;
2151  }
2152  print '</td></tr>';
2153 
2154  // Login
2155  print "<tr>".'<td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
2156  print '<td>';
2157  if ($user->admin && !$object->ldap_sid) {
2158  print '<input maxlength="50" type="text" class="flat" name="login" value="'.$object->login.'">';
2159  } else {
2160  print '<input type="hidden" name="login" value="'.$object->login.'">';
2161  print $object->login;
2162  }
2163  print '</td>';
2164  print '</tr>';
2165 
2166  // Administrator
2167  print '<tr><td>'.$langs->trans("Administrator").'</td>';
2168  if ($object->socid > 0) {
2169  $langs->load("admin");
2170  print '<td>';
2171  print '<input type="hidden" name="admin" value="'.$object->admin.'">'.yn($object->admin);
2172  print ' ('.$langs->trans("ExternalUser").')';
2173  print '</td></tr>';
2174  } else {
2175  print '<td>';
2176  $nbAdmin = $user->getNbOfUsers('active', '', 1);
2177  $nbSuperAdmin = $user->getNbOfUsers('active', 'superadmin', 1);
2178  //var_dump($nbAdmin);
2179  //var_dump($nbSuperAdmin);
2180  if ($user->admin // Need to be admin to allow downgrade of an admin
2181  && ($user->id != $object->id) // Don't downgrade ourself
2182  && (
2183  (!isModEnabled('multicompany') && $nbAdmin >= 1)
2184  || (isModEnabled('multicompany') && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone
2185  )
2186  ) {
2187  print $form->selectyesno('admin', $object->admin, 1);
2188 
2189  if (isModEnabled('multicompany') && !$user->entity) {
2190  if ($conf->use_javascript_ajax) {
2191  print '<script type="text/javascript">
2192  $(function() {
2193  var admin = $("select[name=admin]").val();
2194  if (admin == 0) {
2195  $("input[name=superadmin]")
2196  .prop("disabled", true)
2197  .prop("checked", false);
2198  }
2199  if ($("input[name=superadmin]").is(":checked")) {
2200  $("select[name=entity]")
2201  .prop("disabled", true);
2202  }
2203  $("select[name=admin]").change(function() {
2204  if ( $(this).val() == 0 ) {
2205  $("input[name=superadmin]")
2206  .prop("disabled", true)
2207  .prop("checked", false);
2208  $("select[name=entity]")
2209  .prop("disabled", false);
2210  } else {
2211  $("input[name=superadmin]")
2212  .prop("disabled", false);
2213  }
2214  });
2215  $("input[name=superadmin]").change(function() {
2216  if ( $(this).is(":checked")) {
2217  $("select[name=entity]")
2218  .prop("disabled", true);
2219  } else {
2220  $("select[name=entity]")
2221  .prop("disabled", false);
2222  }
2223  });
2224  });
2225  </script>';
2226  }
2227 
2228  $checked = (($object->admin && !$object->entity) ? ' checked' : '');
2229  print '<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.' /> <label for="superadmin">'.$langs->trans("SuperAdministrator").'</span>';
2230  }
2231  } else {
2232  $yn = yn($object->admin);
2233  print '<input type="hidden" name="admin" value="'.$object->admin.'">';
2234  print '<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).'">';
2235  if (isModEnabled('multicompany') && empty($object->entity)) {
2236  print $form->textwithpicto($yn, $langs->trans("DontDowngradeSuperAdmin"), 1, 'warning');
2237  } else {
2238  print $yn;
2239  }
2240  }
2241  print '</td></tr>';
2242  }
2243 
2244  // Gender
2245  print '<tr><td>'.$langs->trans("Gender").'</td>';
2246  print '<td>';
2247  $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
2248  if ($caneditfield) {
2249  print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ?GETPOST('gender') : $object->gender, 1);
2250  } else {
2251  print $arraygender[$object->gender];
2252  }
2253  print '</td></tr>';
2254 
2255  // Employee
2256  print '<tr>';
2257  print '<td>'.$form->editfieldkey('Employee', 'employee', '', $object, 0).'</td><td>';
2258  if ($caneditfield) {
2259  print '<input type="checkbox" name="employee" value="1"'.($object->employee ? ' checked="checked"' : '').'>';
2260  //print $form->selectyesno("employee", $object->employee, 1);
2261  } else {
2262  print '<input type="checkbox" name="employee" disabled value="1"'.($object->employee ? ' checked="checked"' : '').'>';
2263  /*if ($object->employee) {
2264  print $langs->trans("Yes");
2265  } else {
2266  print $langs->trans("No");
2267  }*/
2268  }
2269  print '</td></tr>';
2270 
2271  // Hierarchy
2272  print '<tr><td class="titlefieldcreate">'.$langs->trans("HierarchicalResponsible").'</td>';
2273  print '<td>';
2274  if ($caneditfield) {
2275  print img_picto('', 'user').$form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
2276  } else {
2277  print '<input type="hidden" name="fk_user" value="'.$object->fk_user.'">';
2278  $huser = new User($db);
2279  $huser->fetch($object->fk_user);
2280  print $huser->getNomUrl(1);
2281  }
2282  print '</td>';
2283  print "</tr>\n";
2284 
2285  // Expense report validator
2286  if (isModEnabled('expensereport')) {
2287  print '<tr><td class="titlefieldcreate">';
2288  $text = $langs->trans("ForceUserExpenseValidator");
2289  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
2290  print '</td>';
2291  print '<td>';
2292  if ($caneditfield) {
2293  print img_picto('', 'user').$form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
2294  } else {
2295  print '<input type="hidden" name="fk_user_expense_validator" value="'.$object->fk_user_expense_validator.'">';
2296  $evuser = new User($db);
2297  $evuser->fetch($object->fk_user_expense_validator);
2298  print $evuser->getNomUrl(1);
2299  }
2300  print '</td>';
2301  print "</tr>\n";
2302  }
2303 
2304  // Holiday request validator
2305  if (isModEnabled('holiday')) {
2306  print '<tr><td class="titlefieldcreate">';
2307  $text = $langs->trans("ForceUserHolidayValidator");
2308  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
2309  print '</td>';
2310  print '<td>';
2311  if ($caneditfield) {
2312  print img_picto('', 'user').$form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
2313  } else {
2314  print '<input type="hidden" name="fk_user_holiday_validator" value="'.$object->fk_user_holiday_validator.'">';
2315  $hvuser = new User($db);
2316  $hvuser->fetch($object->fk_user_holiday_validator);
2317  print $hvuser->getNomUrl(1);
2318  }
2319  print '</td>';
2320  print "</tr>\n";
2321  }
2322 
2323  // External user ?
2324  print '<tr><td>'.$langs->trans("ExternalUser").' ?</td>';
2325  print '<td>';
2326  if ($user->id == $object->id || !$user->admin) {
2327  // Read mode
2328  $type = $langs->trans("Internal");
2329  if ($object->socid) {
2330  $type = $langs->trans("External");
2331  }
2332  print $form->textwithpicto($type, $langs->trans("InternalExternalDesc"));
2333  if ($object->ldap_sid) {
2334  print ' ('.$langs->trans("DomainUser").')';
2335  }
2336  } else {
2337  // Select mode
2338  $type = 0;
2339  if ($object->contact_id) {
2340  $type = $object->contact_id;
2341  }
2342 
2343  if ($object->socid > 0 && !($object->contact_id > 0)) { // external user but no link to a contact
2344  print img_picto('', 'company').$form->select_company($object->socid, 'socid', '', '&nbsp;', 0, 0, null, 0, 'maxwidth300');
2345  print img_picto('', 'contact').$form->selectcontacts(0, 0, 'contactid', 1, '', '', 1, 'maxwidth300', false, 1);
2346  if ($object->ldap_sid) {
2347  print ' ('.$langs->trans("DomainUser").')';
2348  }
2349  } elseif ($object->socid > 0 && $object->contact_id > 0) { // external user with a link to a contact
2350  print img_picto('', 'company').$form->select_company($object->socid, 'socid', '', '&nbsp;', 0, 0, null, 0, 'maxwidth300'); // We keep thirdparty empty, contact is already set
2351  print img_picto('', 'contact').$form->selectcontacts(0, $object->contact_id, 'contactid', 1, '', '', 1, 'maxwidth300', false, 1);
2352  if ($object->ldap_sid) {
2353  print ' ('.$langs->trans("DomainUser").')';
2354  }
2355  } elseif (!($object->socid > 0) && $object->contact_id > 0) { // internal user with a link to a contact
2356  print img_picto('', 'company').$form->select_company(0, 'socid', '', '&nbsp;', 0, 0, null, 0, 'maxwidth300'); // We keep thirdparty empty, contact is already set
2357  print img_picto('', 'contact').$form->selectcontacts(0, $object->contact_id, 'contactid', 1, '', '', 1, 'maxwidth300', false, 1);
2358  if ($object->ldap_sid) {
2359  print ' ('.$langs->trans("DomainUser").')';
2360  }
2361  } else { // $object->socid is not > 0 here
2362  print img_picto('', 'company').$form->select_company(0, 'socid', '', '&nbsp;', 0, 0, null, 0, 'maxwidth300'); // We keep thirdparty empty, contact is already set
2363  print img_picto('', 'contact').$form->selectcontacts(0, 0, 'contactid', 1, '', '', 1, 'maxwidth300', false, 1);
2364  }
2365  }
2366  print '</td></tr>';
2367 
2368 
2369  print '</table>';
2370 
2371  print '<hr>';
2372 
2373  print '<table class="border centpercent">';
2374 
2375  // Date access validity
2376  print '<tr><td>'.$langs->trans("RangeOfLoginValidity").'</td>';
2377  print '<td>';
2378  if ($caneditfield) {
2379  print $form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1, 0, '', '', '', '', 1, '', '');
2380  } else {
2381  print dol_print_date($object->datestartvalidity, 'day');
2382  }
2383 
2384  /*if ($datestartvalidity && $dateendvalidity) {
2385  print ' - ';
2386  }*/
2387  print ' &nbsp; ';
2388 
2389  if ($caneditfield) {
2390  print $form->selectDate($dateendvalidity ? $datendevalidity : $object->dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0, 0, '', '', '', '', 1, '', '');
2391  } else {
2392  print dol_print_date($object->dateendvalidity, 'day');
2393  }
2394  print '</td>';
2395  print "</tr>\n";
2396 
2397  // Pass
2398  print '<tr><td class="titlefieldcreate">'.$langs->trans("Password").'</td>';
2399  print '<td>';
2400  $valuetoshow = '';
2401  if (preg_match('/ldap/', $dolibarr_main_authentication)) {
2402  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP");
2403  }
2404  if (preg_match('/http/', $dolibarr_main_authentication)) {
2405  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning');
2406  }
2407  if (preg_match('/dolibarr/', $dolibarr_main_authentication)) {
2408  if ($caneditpassword) {
2409  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<input maxlength="128" type="password" class="flat" id="password" name="password" value="'.dol_escape_htmltag($object->pass).'" autocomplete="new-password">';
2410  } else {
2411  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass);
2412  }
2413  }
2414 
2415  // Other form for user password
2416  $parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword);
2417  $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2418  if ($reshook > 0) {
2419  $valuetoshow = $hookmanager->resPrint; // to replace
2420  } else {
2421  $valuetoshow .= $hookmanager->resPrint; // to add
2422  }
2423 
2424  print $valuetoshow;
2425  print "</td></tr>\n";
2426 
2427  // API key
2428  if (isModEnabled('api')) {
2429  print '<tr><td>'.$langs->trans("ApiKey").'</td>';
2430  print '<td>';
2431  if ($caneditpassword || $user->hasRight("api", "apikey", "generate")) {
2432  print '<input class="minwidth300" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">';
2433  if (!empty($conf->use_javascript_ajax)) {
2434  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
2435  }
2436  }
2437  print '</td></tr>';
2438  }
2439 
2440  // OpenID url
2441  if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
2442  print "<tr>".'<td>'.$langs->trans("OpenIDURL").'</td>';
2443  print '<td>';
2444  if ($caneditfield) {
2445  print '<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.'">';
2446  } else {
2447  print '<input type="hidden" name="openid" value="'.$object->openid.'">';
2448  print $object->openid;
2449  }
2450  print '</td></tr>';
2451  }
2452 
2453  print '</table><hr><table class="border centpercent">';
2454 
2455 
2456  // Address
2457  print '<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
2458  print '<td>';
2459  if ($caneditfield) {
2460  print '<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2461  }
2462  print $object->address;
2463  if ($caneditfield) {
2464  print '</textarea>';
2465  }
2466  print '</td></tr>';
2467 
2468  // Zip
2469  print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
2470  if ($caneditfield) {
2471  print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
2472  } else {
2473  print $object->zip;
2474  }
2475  print '</td></tr>';
2476 
2477  // Town
2478  print '<tr><td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
2479  if ($caneditfield) {
2480  print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
2481  } else {
2482  print $object->town;
2483  }
2484  print '</td></tr>';
2485 
2486  // Country
2487  print '<tr><td>'.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).'</td><td>';
2488  if ($caneditfield) {
2489  print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id');
2490  if ($user->admin) {
2491  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2492  }
2493  } else {
2494  $countrylabel = getCountry($object->country_id, '0');
2495  print $countrylabel;
2496  }
2497  print '</td></tr>';
2498 
2499  // State
2500  if (empty($conf->global->USER_DISABLE_STATE)) {
2501  print '<tr><td class="tdoverflow">'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td>';
2502  if ($caneditfield) {
2503  print img_picto('', 'state', 'class="pictofixedwidth"');
2504  print $formcompany->select_state($object->state_id, $object->country_code, 'state_id');
2505  } else {
2506  print $object->state_label;
2507  }
2508  print '</td></tr>';
2509  }
2510 
2511  // Tel pro
2512  print "<tr>".'<td>'.$langs->trans("PhonePro").'</td>';
2513  print '<td>';
2514  print img_picto('', 'phoning', 'class="pictofixedwidth"');
2515  if ($caneditfield && empty($object->ldap_sid)) {
2516  print '<input type="text" name="office_phone" class="flat maxwidth200" value="'.$object->office_phone.'">';
2517  } else {
2518  print '<input type="hidden" name="office_phone" value="'.$object->office_phone.'">';
2519  print $object->office_phone;
2520  }
2521  print '</td></tr>';
2522 
2523  // Tel mobile
2524  print "<tr>".'<td>'.$langs->trans("PhoneMobile").'</td>';
2525  print '<td>';
2526  print img_picto('', 'phoning_mobile', 'class="pictofixedwidth"');
2527  if ($caneditfield && empty($object->ldap_sid)) {
2528  print '<input type="text" name="user_mobile" class="flat maxwidth200" value="'.$object->user_mobile.'">';
2529  } else {
2530  print '<input type="hidden" name="user_mobile" value="'.$object->user_mobile.'">';
2531  print $object->user_mobile;
2532  }
2533  print '</td></tr>';
2534 
2535  // Fax
2536  print "<tr>".'<td>'.$langs->trans("Fax").'</td>';
2537  print '<td>';
2538  print img_picto('', 'phoning_fax', 'class="pictofixedwidth"');
2539  if ($caneditfield && empty($object->ldap_sid)) {
2540  print '<input type="text" name="office_fax" class="flat maxwidth200" value="'.$object->office_fax.'">';
2541  } else {
2542  print '<input type="hidden" name="office_fax" value="'.$object->office_fax.'">';
2543  print $object->office_fax;
2544  }
2545  print '</td></tr>';
2546 
2547  // EMail
2548  print "<tr>".'<td'.(!empty($conf->global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.$langs->trans("EMail").'</td>';
2549  print '<td>';
2550  print img_picto('', 'object_email', 'class="pictofixedwidth"');
2551  if ($caneditfield && empty($object->ldap_sid)) {
2552  print '<input class="minwidth100 maxwidth500 widthcentpercentminusx" type="text" name="email" class="flat" value="'.$object->email.'">';
2553  } else {
2554  print '<input type="hidden" name="email" value="'.$object->email.'">';
2555  print $object->email;
2556  }
2557  print '</td></tr>';
2558 
2559  if (isModEnabled('socialnetworks')) {
2560  foreach ($socialnetworks as $key => $value) {
2561  if ($value['active']) {
2562  print '<tr><td>'.$langs->trans($value['label']).'</td>';
2563  print '<td>';
2564  if (!empty($value['icon'])) {
2565  print '<span class="fa '.$value['icon'].' pictofixedwidth"></span>';
2566  }
2567  if ($caneditfield && empty($object->ldap_sid)) {
2568  print '<input type="text" name="'.$key.'" class="flat maxwidth200" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:'').'">';
2569  } else {
2570  print '<input type="hidden" name="'.$key.'" value="'.$object->socialnetworks[$key].'">';
2571  print $object->socialnetworks[$key];
2572  }
2573  print '</td></tr>';
2574  } else {
2575  // if social network is not active but value exist we do not want to loose it
2576  print '<input type="hidden" name="'.$key.'" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:'').'">';
2577  }
2578  }
2579  }
2580 
2581  print '</table><hr><table class="border centpercent">';
2582 
2583  // Default warehouse
2584  if (isModEnabled('stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
2585  print '<tr><td class="titlefield">'.$langs->trans("DefaultWarehouse").'</td><td>';
2586  print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1);
2587  print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&token='.newToken().'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken()).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddWarehouse").'"></span></a>';
2588  print '</td></tr>';
2589  }
2590 
2591  // Accountancy code
2592  if (isModEnabled('accounting')) {
2593  print "<tr>";
2594  print '<td class="titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
2595  print '<td>';
2596  if ($caneditfield) {
2597  print '<input type="text" class="flat maxwidth300" name="accountancy_code" value="'.$object->accountancy_code.'">';
2598  } else {
2599  print '<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.'">';
2600  print $object->accountancy_code;
2601  }
2602  print '</td>';
2603  print "</tr>";
2604  }
2605 
2606  // User color
2607  if (isModEnabled('agenda')) {
2608  print '<tr><td class="titlefieldcreate">'.$langs->trans("ColorUser").'</td>';
2609  print '<td>';
2610  if ($caneditfield) {
2611  print $formother->selectColor(GETPOSTISSET('color') ?GETPOST('color', 'alphanohtml') : $object->color, 'color', null, 1, '', 'hideifnotset');
2612  } else {
2613  print $formother->showColor($object->color, '');
2614  }
2615  print '</td></tr>';
2616  }
2617 
2618  // Photo
2619  print '<tr>';
2620  print '<td class="titlefieldcreate">'.$langs->trans("Photo").'</td>';
2621  print '<td>';
2622  print $form->showphoto('userphoto', $object, 60, 0, $caneditfield, 'photowithmargin', 'small', 1, 0, 'user', 1);
2623  print '</td>';
2624  print '</tr>';
2625 
2626  // Categories
2627  if (isModEnabled('categorie') && $user->hasRight("categorie", "read")) {
2628  print '<tr><td>'.$form->editfieldkey('Categories', 'usercats', '', $object, 0).'</td>';
2629  print '<td>';
2630  print img_picto('', 'category', 'class="pictofixedwidth"');
2631  $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER, null, null, null, null, 1);
2632  $c = new Categorie($db);
2633  $cats = $c->containing($object->id, Categorie::TYPE_USER);
2634  $arrayselected = array();
2635  foreach ($cats as $cat) {
2636  $arrayselected[] = $cat->id;
2637  }
2638  if ($caneditfield) {
2639  print $form->multiselectarray('usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
2640  } else {
2641  print $form->showCategories($object->id, Categorie::TYPE_USER, 1);
2642  }
2643  print "</td></tr>";
2644  }
2645 
2646  // Default language
2647  if (getDolGlobalInt('MAIN_MULTILANGS')) {
2648  print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0, 'string', '', 0, 0, 'id', $langs->trans("WarningNotLangOfInterface", $langs->transnoentitiesnoconv("UserGUISetup"))).'</td><td colspan="3">'."\n";
2649  print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($object->lang, 'default_lang', 0, null, '1', 0, 0, 'widthcentpercentminusx maxwidth300');
2650  print '</td>';
2651  print '</tr>';
2652  }
2653 
2654  // Status
2655  print '<tr><td>'.$langs->trans("Status").'</td>';
2656  print '<td>';
2657  print $object->getLibStatut(4);
2658  print '</td></tr>';
2659 
2660  // Company / Contact
2661  if (isModEnabled("societe")) {
2662  print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>';
2663  print '<td>';
2664  if ($object->socid > 0) {
2665  $societe = new Societe($db);
2666  $societe->fetch($object->socid);
2667  print $societe->getNomUrl(1, '');
2668  if ($object->contact_id) {
2669  $contact = new Contact($db);
2670  $contact->fetch($object->contact_id);
2671  print ' / <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"), 'contact').' '.dol_trunc($contact->getFullName($langs), 32).'</a>';
2672  }
2673  } else {
2674  print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ThisUserIsNot").'</span>';
2675  }
2676  print ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("UseTypeFieldToChange").')</span>';
2677  print '</td>';
2678  print "</tr>\n";
2679  }
2680 
2681  // Module Adherent
2682  if (isModEnabled('adherent')) {
2683  $langs->load("members");
2684  print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
2685  print '<td>';
2686  if ($object->fk_member) {
2687  $adh = new Adherent($db);
2688  $adh->fetch($object->fk_member);
2689  $adh->ref = $adh->login; // Force to show login instead of id
2690  print $adh->getNomUrl(1);
2691  } else {
2692  print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("UserNotLinkedToMember").'</span>';
2693  }
2694  print '</td>';
2695  print "</tr>\n";
2696  }
2697 
2698  // Multicompany
2699  // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !!
2700  if (isModEnabled('multicompany') && is_object($mc)) {
2701  // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
2702  if (!method_exists($mc, 'formObjectOptions')) {
2703  if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) {
2704  print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
2705  print "<td>".$mc->select_entities($object->entity, 'entity', '', 0, 1, false, false, 1); // last parameter 1 means, show also a choice 0=>'all entities'
2706  print "</td></tr>\n";
2707  } else {
2708  print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
2709  }
2710  }
2711  }
2712 
2713  // Other attributes
2714  $parameters = array('colspan' => ' colspan="2"');
2715  //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // We do not use common tpl here because we need a special test on $caneditfield
2716  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2717  print $hookmanager->resPrint;
2718  if (empty($reshook)) {
2719  if ($caneditfield) {
2720  print $object->showOptionals($extrafields, 'edit');
2721  } else {
2722  print $object->showOptionals($extrafields, 'view');
2723  }
2724  }
2725 
2726  // Signature
2727  print '<tr><td class="tdtop">'.$langs->trans("Signature").'</td>';
2728  print '<td>';
2729  if ($caneditfield) {
2730  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2731 
2732  $doleditor = new DolEditor('signature', $object->signature, '', 138, 'dolibarr_notes', 'In', false, $acceptlocallinktomedia, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%');
2733  print $doleditor->Create(1);
2734  } else {
2735  print dol_htmlentitiesbr($object->signature);
2736  }
2737  print '</td></tr>';
2738 
2739 
2740  print '</table>';
2741 
2742  print '<hr>';
2743 
2744 
2745  print '<table class="border centpercent">';
2746 
2747 
2748  // TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
2749 
2750  // Position/Job
2751  print '<tr><td class="titlefieldcreate">'.$langs->trans("PostOrFunction").'</td>';
2752  print '<td>';
2753  if ($caneditfield) {
2754  print '<input type="text" class="minwidth300 maxwidth500" name="job" value="'.dol_escape_htmltag($object->job).'">';
2755  } else {
2756  print '<input type="hidden" name="job" value="'.dol_escape_htmltag($object->job).'">';
2757  print dol_escape_htmltag($object->job);
2758  }
2759  print '</td></tr>';
2760 
2761  // Weeklyhours
2762  print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
2763  print '<td>';
2764  if ($caneditfield) {
2765  print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours') ?GETPOST('weeklyhours') : $object->weeklyhours).'">';
2766  } else {
2767  print price2num($object->weeklyhours);
2768  }
2769  print '</td>';
2770  print "</tr>\n";
2771 
2772  // Sensitive salary/value information
2773  if ((empty($user->socid) && in_array($id, $childids)) // A user can always see salary/value information for its subordinates
2774  || (!empty($conf->salaries->enabled) && $user->hasRight("salaries", "readall"))
2775  || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) {
2776  $langs->load("salaries");
2777 
2778  // Salary
2779  print '<tr><td>'.$langs->trans("Salary").'</td>';
2780  print '<td>';
2781  print img_picto('', 'salary', 'class="pictofixedwidth paddingright"').'<input size="8" type="text" name="salary" value="'.price2num(GETPOST('salary') ?GETPOST('salary') : $object->salary).'">';
2782  print '</td>';
2783  print "</tr>\n";
2784 
2785  // THM
2786  print '<tr><td>';
2787  $text = $langs->trans("THM");
2788  print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
2789  print '</td>';
2790  print '<td>';
2791  if ($caneditfield) {
2792  print '<input size="8" type="text" name="thm" value="'.price2num(GETPOST('thm') ?GETPOST('thm') : $object->thm).'">';
2793  } else {
2794  print ($object->thm != '' ?price($object->thm, '', $langs, 1, -1, -1, $conf->currency) : '');
2795  }
2796  print '</td>';
2797  print "</tr>\n";
2798 
2799  // TJM
2800  print '<tr><td>';
2801  $text = $langs->trans("TJM");
2802  print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm');
2803  print '</td>';
2804  print '<td>';
2805  if ($caneditfield) {
2806  print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm') ?GETPOST('tjm') : $object->tjm).'">';
2807  } else {
2808  print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : '');
2809  }
2810  print '</td>';
2811  print "</tr>\n";
2812  }
2813 
2814  // Date employment
2815  print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
2816  print '<td>';
2817  if ($caneditfield) {
2818  print $form->selectDate($dateemployment ? $dateemployment : $object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 1);
2819  } else {
2820  print dol_print_date($object->dateemployment, 'day');
2821  }
2822 
2823  if ($dateemployment && $dateemploymentend) {
2824  print ' - ';
2825  }
2826 
2827  if ($caneditfield) {
2828  print $form->selectDate($dateemploymentend ? $dateemploymentend : $object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0);
2829  } else {
2830  print dol_print_date($object->dateemploymentend, 'day');
2831  }
2832  print '</td>';
2833  print "</tr>\n";
2834 
2835  // Date birth
2836  print '<tr><td>'.$langs->trans("DateOfBirth").'</td>';
2837  print '<td>';
2838  if ($caneditfield) {
2839  echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth, 'dateofbirth', 0, 0, 1, 'updateuser', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
2840  } else {
2841  print dol_print_date($object->birth, 'day', 'tzserver');
2842  }
2843  print '</td>';
2844  print "</tr>\n";
2845 
2846  print '</table>';
2847 
2848  print dol_get_fiche_end();
2849 
2850  print '<div class="center">';
2851  print '<input value="'.$langs->trans("Save").'" class="button button-save" type="submit" name="save">';
2852  print '&nbsp; &nbsp; &nbsp;';
2853  print '<input value="'.$langs->trans("Cancel").'" class="button button-cancel" type="submit" name="cancel">';
2854  print '</div>';
2855 
2856  print '</form>';
2857  }
2858 
2859  if ($action != 'edit' && $action != 'presend') {
2860  print '<div class="fichecenter"><div class="fichehalfleft">';
2861 
2862  // Generated documents
2863  $filename = dol_sanitizeFileName($object->ref);
2864  $filedir = $conf->user->dir_output."/".dol_sanitizeFileName($object->ref);
2865  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
2866  $genallowed = $user->hasRight("user", "user", "read");
2867  $delallowed = $user->hasRight("user", "user", "write");
2868 
2869  print $formfile->showdocuments('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', empty($soc->default_lang) ? '' : $soc->default_lang);
2870  $somethingshown = $formfile->numoffiles;
2871 
2872  // Show links to link elements
2873  $linktoelem = $form->showLinkToObjectBlock($object, null, null);
2874  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2875 
2876  print '</div><div class="fichehalfright">';
2877 
2878  // List of actions on element
2879  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
2880  $formactions = new FormActions($db);
2881  $somethingshown = $formactions->showactions($object, 'user', $socid, 1, 'listactions', 0, '', '', $object->id);
2882 
2883  print '</div></div>';
2884  }
2885 
2886  if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) {
2887  $ldap->unbind();
2888  }
2889  }
2890 }
2891 
2892 // Add button to autosuggest a key
2893 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
2894 print dolJSToSetRandomPassword('password', 'generate_password', 0);
2895 if (isModEnabled('api')) {
2896  print dolJSToSetRandomPassword('api_key', 'generate_api_key', 1);
2897 }
2898 
2899 // End of page
2900 llxFooter();
2901 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:449
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage members of a foundation.
Class to manage categories.
Class to manage contact/addresses.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to generate html code for admin pages.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage LDAP features.
Definition: ldap.class.php:35
const SYNCHRO_LDAP_TO_DOLIBARR
Ldap to Dolibarr synchronization.
Definition: ldap.class.php:138
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage user groups.
Class to manage Dolibarr users.
Definition: user.class.php:47
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
$parameters
Actions.
Definition: card.php:79
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
Definition: files.lib.php:1402
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
Definition: files.lib.php:1251
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Make control on an uploaded file from an GUI page and move it to final destination.
Definition: files.lib.php:1112
acceptLocalLinktoMedia()
Check the syntax of some PHP code.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
Definition: images.lib.php:80
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Ouput javacript to autoset a generated password using default module into a HTML element.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.