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