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