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