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