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';
56if (isModEnabled(
'adherent')) {
57 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
59if (isModEnabled(
'categorie')) {
60 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
62if (isModEnabled(
'stock')) {
63 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
67$langs->loadLangs(array(
'users',
'companies',
'ldap',
'admin',
'hrm',
'stocks',
'other'));
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';
77if (empty($id) && $action !=
'create') {
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'));
87$childids = $user->getAllChildIds(1);
89$object =
new User($db);
93$extrafields->fetch_name_optionals_label($object->table_element);
98$hookmanager->initHooks(array(
'usercard',
'globalcard'));
105 $res = $object->fetch($id,
'',
'', 1);
110if ($user->socid > 0) {
111 $socid = $user->socid;
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"));
120$candisableuser = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"delete"));
121$canreadgroup = $canreaduser;
122$caneditgroup = $canedituser;
123if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
124 $canreadgroup = (!empty($user->admin) || $user->hasRight(
"user",
"group_advance",
"read"));
125 $caneditgroup = (!empty($user->admin) || $user->hasRight(
"user",
"group_advance",
"write"));
128if ($user->id != $id && !$canreaduser) {
135 $canedituser = (($user->id == $id) && $user->hasRight(
"user",
"self",
"write")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"write"));
136 $caneditfield = ((($user->id == $id) && $user->hasRight(
"user",
"self",
"write")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"write")));
137 $caneditpassword = ((($user->id == $id) && $user->hasRight(
"user",
"self",
"password")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"password")));
145$parameters = array(
'id' => $id,
'socid' => $socid,
'group' => $group,
'caneditgroup' => $caneditgroup);
146$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
151if (empty($reshook)) {
152 $backurlforlist = DOL_URL_ROOT.
'/user/list.php';
154 if (empty($backtopage) || ($cancel && empty($id))) {
155 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
156 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
157 $backtopage = $backurlforlist;
159 $backtopage = DOL_URL_ROOT.
'/user/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
165 if (!empty($backtopageforcancel)) {
166 header(
"Location: ".$backtopageforcancel);
168 } elseif (!empty($backtopage)) {
169 header(
"Location: ".$backtopage);
175 if ($action ==
'confirm_disable' && $confirm ==
"yes" && $candisableuser) {
176 if ($id != $user->id) {
178 if ($object->admin && empty($user->admin)) {
181 setEventMessages($langs->trans(
"OnlyAdminUsersCanDisableAdminUsers"),
null,
'errors');
183 $object->setstatus(0);
184 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
190 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $candisableuser) {
193 if ($id != $user->id) {
196 if (!empty($conf->file->main_limit_users)) {
197 $nb = $object->getNbOfUsers(
"active");
198 if ($nb >= $conf->file->main_limit_users) {
200 setEventMessages($langs->trans(
"YourQuotaOfUsersIsReached"),
null,
'errors');
205 $object->setstatus(1);
206 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
212 if ($action ==
'confirm_delete' && $confirm ==
"yes" && $candisableuser) {
213 if ($id != $user->id) {
214 if (!GETPOSTISSET(
'token')) {
215 print
'Error, token required for this critical operation';
219 $object =
new User($db);
221 $object->oldcopy = clone $object;
223 $result = $object->delete($user);
225 $langs->load(
"errors");
229 header(
"Location: ".DOL_URL_ROOT.
"/user/list.php?restore_lastsearch_values=1");
236 if ($action ==
'add' && $canadduser) {
250 if (!empty($conf->file->main_limit_users)) {
251 $nb = $object->getNbOfUsers(
"active");
252 if ($nb >= $conf->file->main_limit_users) {
254 setEventMessages($langs->trans(
"YourQuotaOfUsersIsReached"),
null,
'errors');
260 $object->civility_code =
GETPOST(
"civility_code",
'aZ09');
261 $object->lastname =
GETPOST(
"lastname",
'alphanohtml');
262 $object->firstname =
GETPOST(
"firstname",
'alphanohtml');
263 $object->ref_employee =
GETPOST(
"ref_employee",
'alphanohtml');
264 $object->national_registration_number =
GETPOST(
"national_registration_number",
'alphanohtml');
265 $object->login =
GETPOST(
"login",
'alphanohtml');
266 $object->api_key =
GETPOST(
"api_key",
'alphanohtml');
267 $object->gender =
GETPOST(
"gender",
'aZ09');
268 $object->admin =
GETPOST(
"admin",
'int');
269 $object->address =
GETPOST(
'address',
'alphanohtml');
270 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
271 $object->town =
GETPOST(
'town',
'alphanohtml');
272 $object->country_id =
GETPOST(
'country_id',
'int');
273 $object->state_id =
GETPOST(
'state_id',
'int');
274 $object->office_phone =
GETPOST(
"office_phone",
'alphanohtml');
275 $object->office_fax =
GETPOST(
"office_fax",
'alphanohtml');
276 $object->user_mobile =
GETPOST(
"user_mobile",
'alphanohtml');
278 if (isModEnabled(
'socialnetworks')) {
279 $object->socialnetworks = array();
280 foreach ($socialnetworks as $key => $value) {
281 if (
GETPOST($key,
'alphanohtml')) {
282 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
287 $object->email = preg_replace(
'/\s+/',
'',
GETPOST(
"email",
'alphanohtml'));
288 $object->job =
GETPOST(
"job",
'alphanohtml');
289 $object->signature =
GETPOST(
"signature",
'restricthtml');
290 $object->accountancy_code =
GETPOST(
"accountancy_code",
'alphanohtml');
291 $object->note_public =
GETPOST(
"note_public",
'restricthtml');
292 $object->note_private =
GETPOST(
"note_private",
'restricthtml');
293 $object->ldap_sid =
GETPOST(
"ldap_sid",
'alphanohtml');
294 $object->fk_user =
GETPOST(
"fk_user",
'int') > 0 ?
GETPOST(
"fk_user",
'int') : 0;
295 $object->fk_user_expense_validator =
GETPOST(
"fk_user_expense_validator",
'int') > 0 ?
GETPOST(
"fk_user_expense_validator",
'int') : 0;
296 $object->fk_user_holiday_validator =
GETPOST(
"fk_user_holiday_validator",
'int') > 0 ?
GETPOST(
"fk_user_holiday_validator",
'int') : 0;
297 $object->employee =
GETPOST(
'employee',
'alphanohtml');
299 $object->thm =
GETPOST(
"thm",
'alphanohtml') !=
'' ?
GETPOST(
"thm",
'alphanohtml') :
'';
301 $object->tjm =
GETPOST(
"tjm",
'alphanohtml') !=
'' ?
GETPOST(
"tjm",
'alphanohtml') :
'';
303 $object->salary =
GETPOST(
"salary",
'alphanohtml') !=
'' ?
GETPOST(
"salary",
'alphanohtml') :
'';
304 $object->salary =
price2num($object->salary);
305 $object->salaryextra =
GETPOST(
"salaryextra",
'alphanohtml') !=
'' ?
GETPOST(
"salaryextra",
'alphanohtml') :
'';
306 $object->weeklyhours =
GETPOST(
"weeklyhours",
'alphanohtml') !=
'' ?
GETPOST(
"weeklyhours",
'alphanohtml') :
'';
308 $object->color =
GETPOST(
"color",
'alphanohtml') !=
'' ?
GETPOST(
"color",
'alphanohtml') :
'';
310 $object->dateemployment = $dateemployment;
311 $object->dateemploymentend = $dateemploymentend;
312 $object->datestartvalidity = $datestartvalidity;
313 $object->dateendvalidity = $dateendvalidity;
314 $object->birth = $dateofbirth;
316 $object->fk_warehouse =
GETPOST(
'fk_warehouse',
'int');
318 $object->lang =
GETPOST(
'default_lang',
'aZ09');
321 $ret = $extrafields->setOptionalsFromPost(
null, $object);
327 $entity =
GETPOST(
'entity',
'int');
328 if (isModEnabled(
'multicompany')) {
329 if (
GETPOST(
'superadmin',
'int')) {
332 if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
335 $object->entity = ($entity ==
'' ? 1 : $entity);
339 $object->entity = ($entity ==
'' ? 1 : $entity);
347 $id = $object->create($user);
350 if (
GETPOST(
'password',
'none')) {
351 $resPass = $object->setPassword($user,
GETPOST(
'password',
'none'));
353 if (is_int($resPass) && $resPass < 0) {
354 $langs->load(
"errors");
359 if (isModEnabled(
"categorie")) {
361 $usercats =
GETPOST(
'usercats',
'array');
362 $object->setCategories($usercats);
366 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
370 $langs->load(
"errors");
379 if (($action ==
'addgroup' || $action ==
'removegroup') && $caneditgroup) {
382 $editgroup->fetch($group);
383 $editgroup->oldcopy = clone $editgroup;
387 if ($action ==
'addgroup') {
388 $result = $object->SetInGroup($group, $editgroup->entity);
390 if ($action ==
'removegroup') {
391 $result = $object->RemoveFromGroup($group, $editgroup->entity);
402 if ($action ==
'update' && $canedituser) {
403 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
408 if (!
GETPOST(
"lastname",
'alpha')) {
413 if (!
GETPOST(
"login",
'alpha')) {
422 $object->oldcopy = clone $object;
426 $object->civility_code =
GETPOST(
"civility_code",
'aZ09');
427 $object->lastname =
GETPOST(
"lastname",
'alphanohtml');
428 $object->firstname =
GETPOST(
"firstname",
'alphanohtml');
432 if (GETPOSTISSET(
"ref_employee")) {
433 $object->ref_employee =
GETPOST(
"ref_employee",
'alphanohtml');
438 if (GETPOSTISSET(
"national_registration_number")) {
439 $object->national_registration_number =
GETPOST(
"national_registration_number",
'alphanohtml');
441 $object->gender =
GETPOST(
"gender",
'aZ09');
442 if ($caneditpassword) {
443 $object->pass =
GETPOST(
"password",
'none');
445 if ($caneditpassword || $user->hasRight(
"api",
"apikey",
"generate")) {
446 $object->api_key = (
GETPOST(
"api_key",
'alphanohtml')) ?
GETPOST(
"api_key",
'alphanohtml') : $object->api_key;
448 if (!empty($user->admin) && $user->id != $id) {
451 $object->admin =
GETPOST(
"admin",
"int");
453 if ($user->admin && !$object->ldap_sid) {
454 $object->login =
GETPOST(
"login",
'alphanohtml');
456 $object->address =
GETPOST(
'address',
'alphanohtml');
457 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
458 $object->town =
GETPOST(
'town',
'alphanohtml');
459 $object->country_id =
GETPOST(
'country_id',
'int');
460 $object->state_id =
GETPOST(
'state_id',
'int');
461 $object->office_phone =
GETPOST(
"office_phone",
'alphanohtml');
462 $object->office_fax =
GETPOST(
"office_fax",
'alphanohtml');
463 $object->user_mobile =
GETPOST(
"user_mobile",
'alphanohtml');
465 if (isModEnabled(
'socialnetworks')) {
466 $object->socialnetworks = array();
467 foreach ($socialnetworks as $key => $value) {
468 if (
GETPOST($key,
'alphanohtml')) {
469 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
474 $object->email = preg_replace(
'/\s+/',
'',
GETPOST(
"email",
'alphanohtml'));
475 $object->job =
GETPOST(
"job",
'alphanohtml');
476 $object->signature =
GETPOST(
"signature",
'restricthtml');
477 $object->accountancy_code =
GETPOST(
"accountancy_code",
'alphanohtml');
478 $object->openid =
GETPOST(
"openid",
'alphanohtml');
479 $object->fk_user =
GETPOST(
"fk_user",
'int') > 0 ?
GETPOST(
"fk_user",
'int') : 0;
480 $object->fk_user_expense_validator =
GETPOST(
"fk_user_expense_validator",
'int') > 0 ?
GETPOST(
"fk_user_expense_validator",
'int') : 0;
481 $object->fk_user_holiday_validator =
GETPOST(
"fk_user_holiday_validator",
'int') > 0 ?
GETPOST(
"fk_user_holiday_validator",
'int') : 0;
482 $object->employee =
GETPOST(
'employee',
'int');
484 $object->thm =
GETPOST(
"thm",
'alphanohtml') !=
'' ?
GETPOST(
"thm",
'alphanohtml') :
'';
486 $object->tjm =
GETPOST(
"tjm",
'alphanohtml') !=
'' ?
GETPOST(
"tjm",
'alphanohtml') :
'';
488 $object->salary =
GETPOST(
"salary",
'alphanohtml') !=
'' ?
GETPOST(
"salary",
'alphanohtml') :
'';
489 $object->salary =
price2num($object->salary);
490 $object->salaryextra =
GETPOST(
"salaryextra",
'alphanohtml') !=
'' ?
GETPOST(
"salaryextra",
'alphanohtml') :
'';
491 $object->salaryextra =
price2num($object->salaryextra);
492 $object->weeklyhours =
GETPOST(
"weeklyhours",
'alphanohtml') !=
'' ?
GETPOST(
"weeklyhours",
'alphanohtml') :
'';
493 $object->weeklyhours =
price2num($object->weeklyhours);
495 $object->color =
GETPOST(
"color",
'alphanohtml') !=
'' ?
GETPOST(
"color",
'alphanohtml') :
'';
496 $object->dateemployment = $dateemployment;
497 $object->dateemploymentend = $dateemploymentend;
498 $object->datestartvalidity = $datestartvalidity;
499 $object->dateendvalidity = $dateendvalidity;
500 $object->birth = $dateofbirth;
502 if (isModEnabled(
'stock')) {
503 $object->fk_warehouse =
GETPOST(
'fk_warehouse',
'int');
506 $object->lang =
GETPOST(
'default_lang',
'aZ09');
509 if (isModEnabled(
'multicompany') && empty($user->entity) && !empty($user->admin)) {
510 if (
GETPOST(
'superadmin',
'int')) {
513 if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
517 $object->entity = (GETPOSTISSET(
'entity') ?
GETPOSTINT(
'entity') : $object->entity);
523 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
531 if (!empty($_FILES[
'photo'][
'name'])) {
537 $langs->load(
"errors");
539 dol_syslog($langs->transnoentities(
"ErrorBadImageFormat"), LOG_INFO);
544 $passwordismodified = 0;
545 if (!empty($object->pass)) {
546 if ($object->pass != $object->pass_indatabase && !
dol_verifyHash($object->pass, $object->pass_indatabase_crypted)) {
547 $passwordismodified = 1;
551 $ret = $object->update($user);
554 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
555 $langs->load(
"errors");
556 setEventMessages($langs->trans(
"ErrorLoginAlreadyExists", $object->login),
null,
'errors');
564 if (!$error && GETPOSTISSET(
'contactid')) {
565 $contactid =
GETPOST(
'contactid',
'int');
566 $socid =
GETPOST(
'socid',
'int');
568 if ($contactid > 0) {
570 $contact->fetch($contactid);
572 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
573 $sql .=
" SET fk_socpeople=".((int) $contactid);
574 if (!empty($contact->socid)) {
575 $sql .=
", fk_soc=".((int) $contact->socid);
576 } elseif ($socid > 0) {
577 $sql .=
", fk_soc = null";
578 setEventMessages($langs->trans(
"WarningUserDifferentContactSocid"),
null,
'warnings');
580 $sql .=
" WHERE rowid = ".((int) $object->id);
581 } elseif ($socid > 0) {
582 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
583 $sql .=
" SET fk_socpeople=NULL, fk_soc=".((int) $socid);
584 $sql .=
" WHERE rowid = ".((int) $object->id);
586 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
587 $sql .=
" SET fk_socpeople=NULL, fk_soc=NULL";
588 $sql .=
" WHERE rowid = ".((int) $object->id);
591 $resql = $db->query($sql);
598 if (!$error && !count($object->errors)) {
599 if (
GETPOST(
'deletephoto') && $object->oldcopy->photo) {
600 $fileimg = $conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/'.$object->oldcopy->photo;
601 $dirthumbs = $conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/thumbs';
606 if (isset($_FILES[
'photo'][
'tmp_name']) && trim($_FILES[
'photo'][
'tmp_name'])) {
607 $dir = $conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 1, $object,
'user').
'/photos';
613 $result =
dol_move_uploaded_file($_FILES[
'photo'][
'tmp_name'], $newfile, 1, 0, $_FILES[
'photo'][
'error']);
615 if (!($result > 0)) {
619 $object->addThumbs($newfile);
623 $langs->load(
"errors");
624 setEventMessages($langs->trans(
"ErrorFailedToCreateDir", $dir), $mesgs,
'errors');
629 if (!$error && !count($object->errors)) {
631 $categories =
GETPOST(
'usercats',
'array');
632 $object->setCategories($categories);
635 if (!$error && !count($object->errors)) {
639 $login = $_SESSION[
"dol_login"];
640 if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) {
642 $langs->load(
"errors");
643 setEventMessages($langs->transnoentitiesnoconv(
"WarningYourLoginWasModifiedPleaseLogin"),
null,
'warnings');
645 if ($passwordismodified && $object->login == $user->login) {
647 $langs->load(
"errors");
648 setEventMessages($langs->transnoentitiesnoconv(
"WarningYourPasswordWasModifiedPleaseLogin"),
null,
'warnings');
649 header(
"Location: ".DOL_URL_ROOT.
'/user/card.php?id='.$object->id);
657 if ($caneditpassword) {
658 dol_syslog(
"Not allowed to change fields, only password");
662 if (
GETPOST(
"password",
"none")) {
663 $object->oldcopy = clone $object;
665 $ret = $object->setPassword($user,
GETPOST(
"password",
"none"));
666 if (is_int($ret) && $ret < 0) {
675 if ((($action ==
'confirm_password' && $confirm ==
'yes')
676 || ($action ==
'confirm_passwordsend' && $confirm ==
'yes')) && $caneditpassword
680 $newpassword = $object->setPassword($user,
'');
681 if (is_int($newpassword) && $newpassword < 0) {
683 setEventMessages($langs->trans(
"ErrorFailedToSetNewPassword"),
null,
'errors');
686 if ($action ==
'confirm_passwordsend' && $confirm ==
'yes') {
687 if ($object->send_password($user, $newpassword) > 0) {
688 setEventMessages($langs->trans(
"PasswordChangedAndSentTo", $object->email),
null,
'mesgs');
693 setEventMessages($langs->trans(
"PasswordChangedTo", $newpassword),
null,
'warnings');
699 if ($action ==
'adduserldap' && $canadduser) {
700 $selecteduser =
GETPOST(
'users');
702 $required_fields = array(
703 $conf->global->LDAP_KEY_USERS,
704 $conf->global->LDAP_FIELD_NAME,
705 $conf->global->LDAP_FIELD_FIRSTNAME,
706 $conf->global->LDAP_FIELD_LOGIN,
707 $conf->global->LDAP_FIELD_LOGIN_SAMBA,
708 $conf->global->LDAP_FIELD_PASSWORD,
709 $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
710 $conf->global->LDAP_FIELD_PHONE,
711 $conf->global->LDAP_FIELD_FAX,
712 $conf->global->LDAP_FIELD_MOBILE,
713 $conf->global->LDAP_FIELD_SKYPE,
714 $conf->global->LDAP_FIELD_MAIL,
715 $conf->global->LDAP_FIELD_TITLE,
716 $conf->global->LDAP_FIELD_DESCRIPTION,
717 $conf->global->LDAP_FIELD_SID
721 $result = $ldap->connect_bind();
724 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
726 $ldapusers = $ldap->getRecords($selecteduser, $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields);
729 if (is_array($ldapusers)) {
730 foreach ($ldapusers as $key => $attribute) {
731 $ldap_lastname = $attribute[$conf->global->LDAP_FIELD_NAME];
732 $ldap_firstname = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME];
733 $ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN];
734 $ldap_loginsmb = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA];
735 $ldap_pass = $attribute[$conf->global->LDAP_FIELD_PASSWORD];
736 $ldap_pass_crypted = $attribute[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED];
737 $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE];
738 $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX];
739 $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE];
740 $ldap_social[
'skype'] = $attribute[$conf->global->LDAP_FIELD_SKYPE];
741 $ldap_social[
'twitter'] = $attribute[$conf->global->LDAP_FIELD_TWITTER];
742 $ldap_social[
'facebook'] = $attribute[$conf->global->LDAP_FIELD_FACEBOOK];
743 $ldap_social[
'linkedin'] = $attribute[$conf->global->LDAP_FIELD_LINKEDIN];
744 $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL];
745 $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID];
754 $triggersendname =
'USER_SENTBYMAIL';
756 $mode =
'emailfromuser';
757 $trackid =
'use'.$id;
758 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
761 $upload_dir = $conf->user->dir_output;
762 $permissiontoadd = $user->hasRight(
"user",
"user",
"write");
763 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
771$form =
new Form($db);
776if (isModEnabled(
'stock')) {
780if ($object->id > 0) {
781 $person_name = !empty($object->firstname) ? $object->lastname.
", ".$object->firstname : $object->lastname;
782 $title = $person_name.
" - ".$langs->trans(
'Card');
784 if (
GETPOST(
'employee',
'alphanohtml')) {
785 $title = $langs->trans(
"NewEmployee");
787 $title = $langs->trans(
"NewUser");
795if ($action ==
'create' || $action ==
'adduserldap') {
798 print
'<span class="opacitymedium">'.$langs->trans(
"CreateInternalUserDesc").
"</span><br>\n";
805 $result = $ldap->connect_bind();
807 $required_fields = array(
808 $conf->global->LDAP_KEY_USERS,
809 $conf->global->LDAP_FIELD_FULLNAME,
810 $conf->global->LDAP_FIELD_NAME,
811 $conf->global->LDAP_FIELD_FIRSTNAME,
812 $conf->global->LDAP_FIELD_LOGIN,
813 $conf->global->LDAP_FIELD_LOGIN_SAMBA,
814 $conf->global->LDAP_FIELD_PASSWORD,
815 $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
816 $conf->global->LDAP_FIELD_PHONE,
817 $conf->global->LDAP_FIELD_FAX,
818 $conf->global->LDAP_FIELD_MOBILE,
819 $conf->global->LDAP_FIELD_SKYPE,
820 $conf->global->LDAP_FIELD_MAIL,
821 $conf->global->LDAP_FIELD_TITLE,
822 $conf->global->LDAP_FIELD_DESCRIPTION,
823 $conf->global->LDAP_FIELD_SID
827 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
830 $ldapusers = $ldap->getRecords(
'*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
832 if (is_array($ldapusers)) {
834 foreach ($ldapusers as $key => $ldapuser) {
837 foreach ($required_fields as $value) {
838 if ($value === $conf->global->LDAP_FIELD_PASSWORD || $value === $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) {
839 $label .= $value.
"=******* ";
841 $label .= $value.
"=".$ldapuser[$value].
" ";
844 $liste[$key] = $label;
854 print
"\n\n<!-- Form liste LDAP debut -->\n";
856 print
'<form name="add_user_ldap" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
857 print
'<input type="hidden" name="token" value="'.newToken().
'">';
858 print
'<table class="border centpercent"><tr>';
859 print
'<td width="160">';
860 print $langs->trans(
"LDAPUsers");
863 print
'<input type="hidden" name="action" value="adduserldap">';
864 if (is_array($liste) && count($liste)) {
865 print $form->selectarray(
'users', $liste,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth500');
868 print
'</td><td class="center">';
869 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
'Get')).
'"'.(count($liste) ?
'' :
' disabled').
'>';
870 print
'</td></tr></table>';
873 print
"\n<!-- Form liste LDAP fin -->\n\n";
878 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" name="createuser">';
879 print
'<input type="hidden" name="token" value="'.newToken().
'">';
880 print
'<input type="hidden" name="action" value="add">';
881 if (!empty($ldap_sid)) {
882 print
'<input type="hidden" name="ldap_sid" value="'.dol_escape_htmltag($ldap_sid).
'">';
884 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
890 print
'<table class="border centpercent">';
893 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td>';
894 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') : $object->civility_code,
'civility_code');
899 print
'<td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Lastname").
'</span></td>';
901 if (!empty($ldap_lastname)) {
902 print
'<input type="hidden" id="lastname" name="lastname" value="'.dol_escape_htmltag($ldap_lastname).
'">';
903 print $ldap_lastname;
905 print
'<input class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" id="lastname" name="lastname" value="'.dol_escape_htmltag(
GETPOST(
'lastname',
'alphanohtml')).
'">';
910 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td>';
912 if (!empty($ldap_firstname)) {
913 print
'<input type="hidden" name="firstname" value="'.dol_escape_htmltag($ldap_firstname).
'">';
914 print $ldap_firstname;
916 print
'<input id="firstname" class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" name="firstname" value="'.dol_escape_htmltag(
GETPOST(
'firstname',
'alphanohtml')).
'">';
921 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
923 if (!empty($ldap_login)) {
924 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_login).
'">';
926 } elseif (!empty($ldap_loginsmb)) {
927 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_loginsmb).
'">';
928 print $ldap_loginsmb;
930 print
'<input id="login" class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(
GETPOST(
'login',
'alphanohtml')).
'">';
934 if (!empty($conf->use_javascript_ajax)) {
936 jQuery(document).ready(function() {
937 $(".createloginauto").on("change", function(){
938 lastname = $("#lastname").val();
939 firstname = $("#firstname").val();
940 if($(this).attr("id") == "firstname"){
941 firstname = firstname.toLowerCase();
942 firstname = firstname[0];
944 lastname = lastname.toLowerCase();
945 console.log("We create a login from firstname and lastname");
946 $("#login").val(firstname+lastname);
952 $generated_password =
'';
953 if (empty($ldap_sid)) {
956 $password = (GETPOSTISSET(
'password') ?
GETPOST(
'password') : $generated_password);
959 if (!empty($user->admin)) {
960 print
'<tr><td>'.$langs->trans(
"Administrator").
'</td>';
962 print $form->selectyesno(
'admin',
GETPOST(
'admin'), 1);
964 if (isModEnabled(
'multicompany') && !$user->entity) {
965 if (!empty($conf->use_javascript_ajax)) {
966 print
'<script type="text/javascript">
968 $("select[name=admin]").change(function() {
969 if ( $(this).val() == 0 ) {
970 $("input[name=superadmin]")
971 .prop("disabled", true)
972 .prop("checked", false);
973 $("select[name=entity]")
974 .prop("disabled", false);
976 $("input[name=superadmin]")
977 .prop("disabled", false);
980 $("input[name=superadmin]").change(function() {
981 if ( $(this).is(":checked") ) {
982 $("select[name=entity]")
983 .prop("disabled", true);
985 $("select[name=entity]")
986 .prop("disabled", false);
992 $checked = (
GETPOST(
'superadmin',
'int') ?
' checked' :
'');
993 $disabled = (
GETPOST(
'superadmin',
'int') ?
'' :
' disabled');
994 print
'<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.$disabled.
' /> <label for="superadmin">'.$langs->trans(
"SuperAdministrator").
'</span>';
996 print
"</td></tr>\n";
1000 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
1002 $arraygender = array(
'man'=>$langs->trans(
"Genderman"),
'woman'=>$langs->trans(
"Genderwoman"),
'other'=>$langs->trans(
"Genderother"));
1003 print $form->selectarray(
'gender', $arraygender,
GETPOST(
'gender'), 1);
1007 $defaultemployee =
'1';
1009 print
'<td>'.$langs->trans(
'Employee').
'</td><td>';
1010 print
'<input type="checkbox" name="employee" value="1"'.(GETPOST(
'employee') ==
'1' ?
' checked="checked"' : (($defaultemployee && !GETPOSTISSET(
'login')) ?
' checked="checked"' :
'')).
'>';
1015 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"HierarchicalResponsible").
'</td>';
1017 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user,
'fk_user', 1, array($object->id), 0,
'', 0, $conf->entity, 0, 0,
'', 0,
'',
'maxwidth300 widthcentpercentminusx');
1022 if (isModEnabled(
'expensereport')) {
1023 print
'<tr><td class="titlefieldcreate">';
1024 $text = $langs->trans(
"ForceUserExpenseValidator");
1025 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1028 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_expense_validator,
'fk_user_expense_validator', 1, array($object->id), 0,
'', 0, $conf->entity, 0, 0,
'', 0,
'',
'maxwidth300 widthcentpercentminusx');
1034 if (isModEnabled(
'holiday')) {
1035 print
'<tr><td class="titlefieldcreate">';
1036 $text = $langs->trans(
"ForceUserHolidayValidator");
1037 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1040 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_holiday_validator,
'fk_user_holiday_validator', 1, array($object->id), 0,
'', 0, $conf->entity, 0, 0,
'', 0,
'',
'maxwidth300 widthcentpercentminusx');
1046 print
'<tr><td>'.$langs->trans(
"ExternalUser").
' ?</td>';
1048 print $form->textwithpicto($langs->trans(
"Internal"), $langs->trans(
"InternalExternalDesc"), 1,
'help',
'', 0, 2);
1052 print
'</table><hr><table class="border centpercent">';
1056 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
1058 print $form->selectDate($datestartvalidity,
'datestartvalidity', 0, 0, 1,
'formdatestartvalidity', 1, 1);
1062 print $form->selectDate($dateendvalidity,
'dateendvalidity', 0, 0, 1,
'formdateendvalidity', 1, 0);
1067 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Password").
'</td>';
1070 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
1071 $valuetoshow .= ($valuetoshow ?
' + ' :
'').$langs->trans(
"PasswordOfUserInLDAP").
' (hidden)';
1073 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
1074 $valuetoshow .= ($valuetoshow ?
' + ' :
'').$langs->trans(
"HTTPBasicPassword");
1076 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication) || preg_match(
'/forceuser/', $dolibarr_main_authentication)) {
1077 if (!empty($ldap_pass)) {
1078 $valuetoshow .= ($valuetoshow ?
' + ' :
'').
'<input type="hidden" name="password" value="'.
dol_escape_htmltag($ldap_pass).
'">';
1079 $valuetoshow .= preg_replace(
'/./i',
'*', $ldap_pass);
1082 $valuetoshow .= ($valuetoshow ?
' + '.$langs->trans(
"DolibarrPassword") :
'').
'<input class="minwidth300 maxwidth400 widthcentpercentminusx" maxlength="128" type="text" id="password" name="password" value="'.
dol_escape_htmltag($password).
'" autocomplete="new-password">';
1083 if (!empty($conf->use_javascript_ajax)) {
1084 $valuetoshow .=
img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_password" class="linkobject paddingleft"');
1090 $parameters = array(
'valuetoshow' => $valuetoshow,
'password' => $password);
1091 $reshook = $hookmanager->executeHooks(
'printUserPasswordField', $parameters, $object, $action);
1093 $valuetoshow = $hookmanager->resPrint;
1095 $valuetoshow .= $hookmanager->resPrint;
1101 if (isModEnabled(
'api')) {
1104 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
1106 print
'<input class="minwidth300 maxwidth400 widthcentpercentminusx" minlength="12" maxlength="128" type="text" id="api_key" name="api_key" value="'.GETPOST(
'api_key',
'alphanohtml').
'" autocomplete="off">';
1107 if (!empty($conf->use_javascript_ajax)) {
1108 print
img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject paddingleft"');
1114 print
'<input type="hidden" name="api_key" value="'.$generated_fake_api_key.
'">';
1118 print
'</table><hr><table class="border centpercent">';
1122 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
1123 print
'<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1124 print $object->address;
1125 print
'</textarea></td></tr>';
1128 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1129 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
1133 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1134 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1138 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1139 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1140 print $form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $object->country_id));
1142 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1147 if (empty($conf->global->USER_DISABLE_STATE)) {
1148 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1149 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1150 print $formcompany->select_state($object->state_id, $object->country_code,
'state_id');
1155 print
'<tr><td>'.$langs->trans(
"PhonePro").
'</td>';
1157 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1158 if (!empty($ldap_phone)) {
1159 print
'<input type="hidden" name="office_phone" value="'.dol_escape_htmltag($ldap_phone).
'">';
1162 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_phone" value="'.dol_escape_htmltag(
GETPOST(
'office_phone',
'alphanohtml')).
'">';
1167 print
'<tr><td>'.$langs->trans(
"PhoneMobile").
'</td>';
1169 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
1170 if (!empty($ldap_mobile)) {
1171 print
'<input type="hidden" name="user_mobile" value="'.dol_escape_htmltag($ldap_mobile).
'">';
1174 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="user_mobile" value="'.dol_escape_htmltag(
GETPOST(
'user_mobile',
'alphanohtml')).
'">';
1179 print
'<tr><td>'.$langs->trans(
"Fax").
'</td>';
1181 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
1182 if (!empty($ldap_fax)) {
1183 print
'<input type="hidden" name="office_fax" value="'.dol_escape_htmltag($ldap_fax).
'">';
1186 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_fax" value="'.dol_escape_htmltag(
GETPOST(
'office_fax',
'alphanohtml')).
'">';
1191 print
'<tr><td'.(!empty($conf->global->USER_MAIL_REQUIRED) ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
1193 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
1194 if (!empty($ldap_mail)) {
1195 print
'<input type="hidden" name="email" value="'.dol_escape_htmltag($ldap_mail).
'">';
1198 print
'<input type="text" name="email" class="maxwidth500 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'email',
'alphanohtml')).
'">';
1203 if (isModEnabled(
'socialnetworks')) {
1204 foreach ($socialnetworks as $key => $value) {
1205 if ($value[
'active']) {
1206 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
1208 if (!empty($value[
'icon'])) {
1209 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
1211 if (!empty($ldap_social[$key])) {
1212 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1213 print $ldap_social[$key];
1215 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1220 if (!empty($ldap_social[$key])) {
1221 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1223 print
'<input type="hidden" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1230 if (isModEnabled(
'accounting')) {
1231 print
'<tr><td>'.$langs->trans(
"AccountancyCode").
'</td>';
1233 print
'<input type="text" class="maxwidthonsmartphone" name="accountancy_code" value="'.dol_escape_htmltag(
GETPOST(
'accountancy_code',
'alphanohtml')).
'">';
1238 if (isModEnabled(
'agenda')) {
1239 print
'<tr><td>'.$langs->trans(
"ColorUser").
'</td>';
1241 print $formother->selectColor(GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') : $object->color,
'color', null, 1,
'',
'hideifnotset');
1246 if (isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"read")) {
1247 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td><td>';
1248 $cate_arbo = $form->select_all_categories(
'user',
null,
'parent',
null,
null, 1);
1249 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'usercats', $cate_arbo,
GETPOST(
'usercats',
'array'), 0, 0,
'maxwdith300 widthcentpercentminusx', 0,
'90%');
1255 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0,
'string',
'', 0, 0,
'id', $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup"))).
'</td>';
1256 print
'<td class="maxwidthonsmartphone">'.
"\n";
1257 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
GETPOST(
'default_lang',
'alpha') ?
GETPOST(
'default_lang',
'alpha') : ($object->lang ? $object->lang :
''),
'default_lang', 0, 0, 1, 0, 0,
'maxwidth300 widthcentpercentminusx');
1263 if (isModEnabled(
'multicompany') && is_object($mc)) {
1265 if (!method_exists($mc,
'formObjectOptions')) {
1266 if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
1267 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
1268 print
"<td>".$mc->select_entities($conf->entity);
1269 print
"</td></tr>\n";
1271 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
1277 $parameters = array();
1278 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1281 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
1282 print
'<td class="wordbreak">';
1283 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1285 $doleditor =
new DolEditor(
'signature',
GETPOST(
'signature',
'restricthtml'),
'', 138,
'dolibarr_notes',
'In',
true, $acceptlocallinktomedia, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4,
'90%');
1286 print $doleditor->Create(1);
1290 print
'<tr><td class="tdtop">';
1291 print $langs->trans(
"NotePublic");
1293 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1294 $doleditor =
new DolEditor(
'note_public', GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') :
'',
'', 100,
'dolibarr_notes',
'', false, true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC'), ROWS_3,
'90%');
1295 $doleditor->Create();
1296 print
"</td></tr>\n";
1299 print
'<tr><td class="tdtop">';
1300 print $langs->trans(
"NotePrivate");
1302 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1303 $doleditor =
new DolEditor(
'note_private', GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
'',
'', 100,
'dolibarr_notes',
'', false, true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_3,
'90%');
1304 $doleditor->Create();
1305 print
"</td></tr>\n";
1307 print
'</table><hr><table class="border centpercent">';
1313 if (isModEnabled(
'stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1314 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1315 print $formproduct->selectWarehouses($object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
1320 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
1322 print
'<input class="maxwidth200 maxwidth150onsmartphone" type="text" name="job" value="'.dol_escape_htmltag(
GETPOST(
'job',
'alphanohtml')).
'">';
1325 if ((isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"read") && in_array($id, $childids))
1326 || (isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
1327 || (isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
1328 $langs->load(
"salaries");
1332 $text = $langs->trans(
"THM");
1333 print $form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1336 print
'<input size="8" type="text" name="thm" value="'.dol_escape_htmltag(
GETPOST(
'thm')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1342 $text = $langs->trans(
"TJM");
1343 print $form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1346 print
'<input size="8" type="text" name="tjm" value="'.dol_escape_htmltag(
GETPOST(
'tjm')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1351 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1353 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input size="8" type="text" name="salary" value="'.
dol_escape_htmltag(
GETPOST(
'salary')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1359 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1361 print
'<input size="8" type="text" name="weeklyhours" value="'.dol_escape_htmltag(
GETPOST(
'weeklyhours')).
'">';
1366 print
'<tr><td>'.$langs->trans(
"DateOfEmployment").
'</td>';
1368 print $form->selectDate($dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1);
1372 print $form->selectDate($dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0);
1377 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1379 print $form->selectDate($dateofbirth,
'dateofbirth', 0, 0, 1,
'createuser', 1, 0, 0,
'', 0,
'',
'', 1,
'',
'',
'tzserver');
1387 print $form->buttonsSaveCancel(
"CreateUser");
1393 $res = $object->fetch($id,
'',
'', 1);
1398 $res = $object->fetch_optionals();
1401 if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1402 $object->getrights();
1403 if (empty($object->nb_rights) && $object->statut != 0 && empty($object->admin)) {
1410 if (isModEnabled(
'ldap') && !empty($object->ldap_sid)) {
1412 $result = $ldap->connect_bind();
1414 $userSearchFilter =
'('.$conf->global->LDAP_FILTER_CONNECTION.
'('.$ldap->getUserIdentifier().
'='.$object->login.
'))';
1415 $entries = $ldap->fetch($object->login, $userSearchFilter);
1420 $passDoNotExpire = 0;
1421 $userChangePassNextLogon = 0;
1426 if (count($ldap->uacf) > 0) {
1427 foreach ($ldap->uacf as $key => $statut) {
1428 if ($key == 65536) {
1429 $passDoNotExpire = 1;
1430 $statutUACF = $statut;
1435 $statutUACF =
"ACCOUNTDISABLE";
1438 if ($ldap->pwdlastset == 0) {
1439 $userChangePassNextLogon = 1;
1445 if ($mode ==
'employee') {
1446 $title = $langs->trans(
"Employee");
1447 $linkback =
'<a href="'.DOL_URL_ROOT.
'/hrm/employee/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1449 $title = $langs->trans(
"User");
1452 if ($user->hasRight(
"user",
"user",
"read") || $user->admin) {
1453 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1462 if ($action ==
'password') {
1463 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"ReinitPassword"), $langs->trans(
"ConfirmReinitPassword", $object->login),
"confirm_password",
'', 0, 1);
1469 if ($action ==
'passwordsend') {
1470 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"SendNewPassword"), $langs->trans(
"ConfirmSendNewPassword", $object->login),
"confirm_passwordsend",
'', 0, 1);
1476 if ($action ==
'disable') {
1477 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"DisableAUser"), $langs->trans(
"ConfirmDisableUser", $object->login),
"confirm_disable",
'', 0, 1);
1483 if ($action ==
'enable') {
1484 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"EnableAUser"), $langs->trans(
"ConfirmEnableUser", $object->login),
"confirm_enable",
'', 0, 1);
1490 if ($action ==
'delete') {
1491 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"DeleteAUser"), $langs->trans(
"ConfirmDeleteUser", $object->login),
"confirm_delete",
'', 0, 1);
1497 if ($action !=
'edit') {
1500 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/user/vcard.php?id='.$object->id.
'&output=file&file='.urlencode(
dol_sanitizeFileName($object->getFullName($langs).
'.vcf')).
'" class="refid" rel="noopener" rel="noopener">';
1501 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard").
' ('.$langs->trans(
"AddToContacts").
')',
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
1502 $morehtmlref .=
'</a>';
1504 $urltovirtualcard =
'/user/virtualcard.php?id='.((int) $object->id);
1505 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->trans(
"PublicVirtualCardUrl").
' - '.$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'nohover');
1507 dol_banner_tab($object,
'id', $linkback, $user->hasRight(
"user",
"user",
"read") || $user->admin,
'rowid',
'ref', $morehtmlref);
1509 print
'<div class="fichecenter">';
1510 print
'<div class="fichehalfleft">';
1512 print
'<div class="underbanner clearboth"></div>';
1513 print
'<table class="border tableforfield centpercent">';
1516 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Login").
'</td>';
1517 if (!empty($object->ldap_sid) && $object->statut == 0) {
1518 print
'<td class="error">';
1519 print $langs->trans(
"LoginAccountDisableInDolibarr");
1524 if (property_exists($object,
'admin')) {
1525 if (isModEnabled(
'multicompany') && !empty($object->admin) && empty($object->entity)) {
1526 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
1527 } elseif (!empty($object->admin)) {
1528 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
1538 $text = $langs->trans(
"Type");
1539 print $form->textwithpicto($text, $langs->trans(
"InternalExternalDesc"));
1541 $type = $langs->trans(
"Internal");
1542 if ($object->socid > 0) {
1543 $type = $langs->trans(
"External");
1545 print
'<span class="badgeneutral">';
1547 if ($object->ldap_sid) {
1548 print
' ('.$langs->trans(
"DomainUser").
')';
1551 print
'</td></tr>'.
"\n";
1554 if ($object->ldap_sid) {
1555 print
'<tr><td>'.$langs->trans(
"Type").
'</td><td>';
1556 print $langs->trans(
"DomainUser", $ldap->domainFQDN);
1557 print
'</td></tr>'.
"\n";
1561 print
'<tr><td>'.$langs->trans(
"Employee").
'</td><td>';
1562 print
'<input type="checkbox" disabled name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
1564 print
'</td></tr>'.
"\n";
1569 print
'<tr><td>'.$langs->trans(
"HierarchicalResponsible").
'</td>';
1571 if (empty($object->fk_user)) {
1572 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1574 $huser =
new User($db);
1575 if ($object->fk_user > 0) {
1576 $huser->fetch($object->fk_user);
1577 print $huser->getNomUrl(-1);
1579 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1586 if (isModEnabled(
'expensereport')) {
1588 $text = $langs->trans(
"ForceUserExpenseValidator");
1589 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1592 if (!empty($object->fk_user_expense_validator)) {
1593 $evuser =
new User($db);
1594 $evuser->fetch($object->fk_user_expense_validator);
1595 print $evuser->getNomUrl(-1);
1602 if (isModEnabled(
'holiday')) {
1604 $text = $langs->trans(
"ForceUserHolidayValidator");
1605 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1608 if (!empty($object->fk_user_holiday_validator)) {
1609 $hvuser =
new User($db);
1610 $hvuser->fetch($object->fk_user_holiday_validator);
1611 print $hvuser->getNomUrl(-1);
1618 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td>';
1619 print
'<td>'.dol_escape_htmltag($object->job).
'</td>';
1623 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1630 if ((empty($user->socid) && in_array($id, $childids))
1631 || (isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
1632 || (isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
1633 $langs->load(
"salaries");
1636 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1638 print ($object->salary !=
'' ?
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<span class="amount">'.
price($object->salary,
'', $langs, 1, -1, -1, $conf->currency) :
'').
'</span>';
1644 $text = $langs->trans(
"THM");
1645 print $form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1648 print ($object->thm !=
'' ?
price($object->thm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
1654 $text = $langs->trans(
"TJM");
1655 print $form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1658 print ($object->tjm !=
'' ?
price($object->tjm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
1664 print
'<tr><td>'.$langs->trans(
"DateOfEmployment").
'</td>';
1666 if ($object->dateemployment) {
1667 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
1670 if ($object->dateemploymentend) {
1671 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
1678 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1685 if (isModEnabled(
'stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1686 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
1687 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1688 if ($object->fk_warehouse > 0) {
1689 $warehousestatic =
new Entrepot($db);
1690 $warehousestatic->fetch($object->fk_warehouse);
1691 print $warehousestatic->getNomUrl(1);
1699 print
'<div class="fichehalfright">';
1701 print
'<div class="underbanner clearboth"></div>';
1703 print
'<table class="border tableforfield centpercent">';
1706 if (isModEnabled(
'agenda')) {
1707 print
'<tr><td class="titlefield">'.$langs->trans(
"ColorUser").
'</td>';
1709 print $formother->showColor($object->color,
'');
1715 if (isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"read")) {
1716 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1717 print
'<td colspan="3">';
1718 print $form->showCategories($object->id, Categorie::TYPE_USER, 1);
1724 $langs->load(
"languages");
1725 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1726 print
'<tr><td class="titlefield">';
1727 print $form->textwithpicto($langs->trans(
"DefaultLang"), $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup")));
1731 $labellang = ($object->lang ? $langs->trans(
'Language_'.$object->lang) :
'');
1732 print
picto_from_langcode($object->lang,
'class="paddingrightonly saturatemedium opacitylow"');
1737 if (isset($conf->file->main_authentication) && preg_match(
'/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
1738 print
'<tr><td>'.$langs->trans(
"OpenIDURL").
'</td>';
1739 print
'<td>'.$object->openid.
'</td>';
1744 if (isModEnabled(
'multicompany') && is_object($mc)) {
1746 if (!method_exists($mc,
'formObjectOptions')) {
1747 if (isModEnabled(
'multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
1748 print
'<tr><td>'.$langs->trans(
"Entity").
'</td><td>';
1749 if (empty($object->entity)) {
1750 print $langs->trans(
"AllEntities");
1752 $mc->getInfo($object->entity);
1755 print
"</td></tr>\n";
1761 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1764 if (isModEnabled(
"societe")) {
1765 print
'<tr><td>'.$langs->trans(
"LinkToCompanyContact").
'</td>';
1768 if (isset($object->socid) && $object->socid > 0) {
1770 $societe->fetch($object->socid);
1771 if ($societe->id > 0) {
1772 $s .= $societe->getNomUrl(1,
'');
1775 $s .=
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ThisUserIsNot").
'</span>';
1777 if (!empty($object->contact_id)) {
1779 $contact->fetch($object->contact_id);
1780 if ($contact->id > 0) {
1781 if ($object->socid > 0 && $s) {
1786 $s .= $contact->getNomUrl(1,
'');
1795 if (isModEnabled(
'adherent')) {
1796 $langs->load(
"members");
1797 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
1799 if ($object->fk_member) {
1801 $adh->fetch($object->fk_member);
1802 $adh->ref = $adh->getFullname($langs);
1803 print $adh->getNomUrl(-1);
1805 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
1812 print
'<tr><td class="tdtop">'.$langs->trans(
'Signature').
'</td><td class="wordbreak">';
1814 print
"</td></tr>\n";
1821 print
'<div class="div-table-responsive-no-min">';
1822 print
'<table class="border tableforfield centpercent">';
1823 print
'<tr class="liste_titre"><td class="liste_titre">';
1824 print
img_picto(
'',
'security',
'class="paddingleft pictofixedwidth"').$langs->trans(
"Credentials");
1826 print
'<td class="liste_titre"></td>';
1830 print
'<tr class="nooddeven"><td class="titlefield">'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
1832 if ($object->datestartvalidity) {
1833 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
1836 if ($object->dateendvalidity) {
1837 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
1845 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
1846 if (!empty($object->ldap_sid)) {
1847 if ($passDoNotExpire) {
1848 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"LdapUacf_".$statutUACF);
1849 } elseif ($userChangePassNextLogon) {
1850 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"UserMustChangePassNextLogon", $ldap->domainFQDN).
'</span>';
1851 } elseif ($userDisabled) {
1852 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"LdapUacf_".$statutUACF, $ldap->domainFQDN).
'</span>';
1854 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
1857 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
1860 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
1861 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"HTTPBasicPassword");
1882 $parameters = array(
'valuetoshow' => $valuetoshow);
1883 $reshook = $hookmanager->executeHooks(
'printUserPasswordField', $parameters, $object, $action);
1885 $valuetoshow = $hookmanager->resPrint;
1887 $valuetoshow .= $hookmanager->resPrint;
1891 print
'<tr class="nooddeven"><td class="titlefield">'.$langs->trans(
"Password").
'</td>';
1892 print
'<td class="wordbreak">';
1899 if (isModEnabled(
'api') && ($user->id == $id || $user->admin || $user->hasRight(
"api",
"apikey",
"generate"))) {
1900 print
'<tr class="nooddeven"><td>'.$langs->trans(
"ApiKey").
'</td>';
1902 if (!empty($object->api_key)) {
1903 print
'<span class="opacitymedium">';
1910 print
'<tr class="nooddeven"><td>'.$langs->trans(
"LastConnexion").
'</td>';
1912 if ($object->datepreviouslogin) {
1913 print
dol_print_date($object->datepreviouslogin,
"dayhour",
"tzuserrel").
' <span class="opacitymedium">('.$langs->trans(
"Previous").
')</span>, ';
1915 if ($object->datelastlogin) {
1916 print
dol_print_date($object->datelastlogin,
"dayhour",
"tzuserrel").
' <span class="opacitymedium">('.$langs->trans(
"Currently").
')</span>';
1927 print
'<div class="clearboth"></div>';
1936 print
'<div class="tabsAction">';
1938 $parameters = array();
1939 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1940 if (empty($reshook)) {
1941 if (empty($user->socid)) {
1942 $canSendMail =
false;
1946 'class' =>
'classfortooltip'
1949 if (!empty($object->email)) {
1950 $langs->load(
"mails");
1951 $canSendMail =
true;
1953 $langs->load(
"mails");
1954 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
1956 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=presend&mode=init#formmailbeforetitle',
'', $canSendMail, $params);
1959 if ($caneditfield && (!isModEnabled(
'multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1963 'class' =>
'classfortooltip'
1966 if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
1967 $params[
'attr'][
'title'] = $langs->trans(
'DisabledInMonoUserMode');
1968 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1970 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'',
true, $params);
1972 } elseif ($caneditpassword && !$object->ldap_sid &&
1973 (!isModEnabled(
'multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1977 'class' =>
'classfortooltip'
1980 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit',
'',
true, $params);
1987 'class' =>
'classfortooltip'
1990 if ($conf->global->USER_PASSWORD_GENERATED !=
'none') {
1991 if ($object->statut == 0) {
1992 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
1993 print
dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1994 } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
1995 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1996 print
dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=password&token='.newToken(),
'',
true, $params);
1999 if ($object->statut == 0) {
2000 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
2001 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2002 } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
2003 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
2004 if ($object->email) {
2005 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=passwordsend&token='.newToken(),
'',
true, $params);
2007 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
2008 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2017 'class' =>
'classfortooltip'
2020 if ($user->id <> $id && $candisableuser && $object->statut == 0 &&
2021 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
2022 print
dolGetButtonAction($langs->trans(
'Reactivate'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=enable&token='.newToken(),
'',
true, $params);
2025 if ($user->id <> $id && $candisableuser && $object->statut == 1 &&
2026 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
2027 print
dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=disable&token='.newToken(),
'',
true, $params);
2029 if ($user->id == $id) {
2030 $params[
'attr'][
'title'] = $langs->trans(
'CantDisableYourself');
2031 print
dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2035 if ($user->id <> $id && $candisableuser &&
2036 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
2037 if ($user->admin || !$object->admin) {
2038 print
dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.newToken().
'&id='.$object->id,
'',
true, $params);
2040 $params[
'attr'][
'title'] = $langs->trans(
'MustBeAdminToDeleteOtherAdmin');
2041 print
dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.newToken().
'&id='.$object->id,
'',
false, $params);
2051 if (
GETPOST(
'modelselected')) {
2052 $action =
'presend';
2056 $modelmail =
'user';
2057 $defaulttopic =
'Information';
2058 $diroutput = $conf->user->dir_output;
2059 $trackid =
'use'.$object->id;
2061 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
2063 if ($action !=
'presend' && $action !=
'send') {
2068 if ($canreadgroup) {
2069 print
'<!-- Group section -->'.
"\n";
2077 $groupslist = $usergroup->listGroupsForUser($object->id,
false);
2079 if (!empty($groupslist)) {
2080 foreach ($groupslist as $groupforuser) {
2081 $exclude[] = $groupforuser->id;
2086 $parameters = array(
'caneditgroup' => $caneditgroup,
'groupslist' => $groupslist,
'exclude' => $exclude);
2087 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup', $parameters, $object, $action);
2088 print $hookmanager->resPrint;
2090 if (empty($reshook)) {
2091 if ($caneditgroup) {
2092 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">'.
"\n";
2093 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
2094 print
'<input type="hidden" name="action" value="addgroup" />';
2095 print
'<input type="hidden" name="page_y" value="" />';
2098 print
'<!-- List of groups of the user -->'.
"\n";
2099 print
'<table class="noborder centpercent">'.
"\n";
2100 print
'<tr class="liste_titre"><th class="liste_titre">'.$langs->trans(
"Groups").
'</th>'.
"\n";
2101 print
'<th class="liste_titre right">';
2102 if ($caneditgroup) {
2103 print $form->select_dolgroups(
'',
'group', 1, $exclude, 0,
'',
'', $object->entity,
false,
'maxwidth150');
2105 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
2106 print
'<input type="submit" class="button buttongen button-add reposition" value="'.$langs->trans(
"Add").
'" />';
2108 print
'</th></tr>'.
"\n";
2111 if (!empty($groupslist)) {
2112 foreach ($groupslist as $group) {
2113 print
'<tr class="oddeven">';
2114 print
'<td class="tdoverflowmax150">';
2115 if ($caneditgroup) {
2116 print $group->getNomUrl(1);
2118 print
img_object($langs->trans(
"ShowGroup"),
"group").
' '.$group->name;
2121 print
'<td class="right">';
2122 if ($caneditgroup) {
2123 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=removegroup&token='.newToken().
'&group='.((int) $group->id).
'">';
2124 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
2129 print
"</td></tr>\n";
2132 print
'<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
2137 if ($caneditgroup) {
2149 if ($action ==
'edit' && ($canedituser || $caneditpassword)) {
2150 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST" name="updateuser" enctype="multipart/form-data">';
2151 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2152 print
'<input type="hidden" name="action" value="update">';
2153 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2157 print
'<table class="border centpercent">';
2160 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2161 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td>';
2169 print
'<tr><td class="titlefieldcreate"><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td>';
2170 if ($caneditfield && !$object->ldap_sid) {
2171 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') : $object->civility_code,
'civility_code');
2172 } elseif ($object->civility_code) {
2173 print $langs->trans(
"Civility".$object->civility_code);
2179 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Lastname").
'</td>';
2181 if ($caneditfield && !$object->ldap_sid) {
2182 print
'<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.
'">';
2184 print
'<input type="hidden" name="lastname" value="'.$object->lastname.
'">';
2185 print $object->lastname;
2191 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td>';
2193 if ($caneditfield && !$object->ldap_sid) {
2194 print
'<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.
'">';
2196 print
'<input type="hidden" name="firstname" value="'.$object->firstname.
'">';
2197 print $object->firstname;
2202 print
"<tr>".
'<td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
2204 if ($user->admin && !$object->ldap_sid) {
2205 print
'<input maxlength="50" type="text" class="flat" name="login" value="'.$object->login.
'">';
2207 print
'<input type="hidden" name="login" value="'.$object->login.
'">';
2208 print $object->login;
2214 print
'<tr><td>'.$langs->trans(
"Administrator").
'</td>';
2215 if ($object->socid > 0) {
2216 $langs->load(
"admin");
2218 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">'.
yn($object->admin);
2219 print
' ('.$langs->trans(
"ExternalUser").
')';
2223 $nbAdmin = $user->getNbOfUsers(
'active',
'', 1);
2224 $nbSuperAdmin = $user->getNbOfUsers(
'active',
'superadmin', 1);
2228 && ($user->id != $object->id)
2230 (!isModEnabled(
'multicompany') && $nbAdmin >= 1)
2231 || (isModEnabled(
'multicompany') && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1))
2234 print $form->selectyesno(
'admin', $object->admin, 1);
2236 if (isModEnabled(
'multicompany') && !$user->entity) {
2237 if ($conf->use_javascript_ajax) {
2238 print
'<script type="text/javascript">
2240 var admin = $("select[name=admin]").val();
2242 $("input[name=superadmin]")
2243 .prop("disabled", true)
2244 .prop("checked", false);
2246 if ($("input[name=superadmin]").is(":checked")) {
2247 $("select[name=entity]")
2248 .prop("disabled", true);
2250 $("select[name=admin]").change(function() {
2251 if ( $(this).val() == 0 ) {
2252 $("input[name=superadmin]")
2253 .prop("disabled", true)
2254 .prop("checked", false);
2255 $("select[name=entity]")
2256 .prop("disabled", false);
2258 $("input[name=superadmin]")
2259 .prop("disabled", false);
2262 $("input[name=superadmin]").change(function() {
2263 if ( $(this).is(":checked")) {
2264 $("select[name=entity]")
2265 .prop("disabled", true);
2267 $("select[name=entity]")
2268 .prop("disabled", false);
2275 $checked = (($object->admin && !$object->entity) ?
' checked' :
'');
2276 print
'<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.
' /> <label for="superadmin">'.$langs->trans(
"SuperAdministrator").
'</span>';
2279 $yn =
yn($object->admin);
2280 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">';
2281 print
'<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).
'">';
2282 if (isModEnabled(
'multicompany') && empty($object->entity)) {
2283 print $form->textwithpicto($yn, $langs->trans(
"DontDowngradeSuperAdmin"), 1,
'warning');
2292 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
2294 $arraygender = array(
'man'=>$langs->trans(
"Genderman"),
'woman'=>$langs->trans(
"Genderwoman"),
'other'=>$langs->trans(
"Genderother"));
2295 if ($caneditfield) {
2296 print $form->selectarray(
'gender', $arraygender, GETPOSTISSET(
'gender') ?
GETPOST(
'gender') : $object->gender, 1);
2298 print $arraygender[$object->gender];
2304 print
'<td>'.$form->editfieldkey(
'Employee',
'employee',
'', $object, 0).
'</td><td>';
2305 if ($caneditfield) {
2306 print
'<input type="checkbox" name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2309 print
'<input type="checkbox" name="employee" disabled value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2319 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"HierarchicalResponsible").
'</td>';
2321 if ($caneditfield) {
2322 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user,
'fk_user', 1, array($object->id), 0,
'', 0, $object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2324 print
'<input type="hidden" name="fk_user" value="'.$object->fk_user.
'">';
2325 $huser =
new User($db);
2326 $huser->fetch($object->fk_user);
2327 print $huser->getNomUrl(-1);
2333 if (isModEnabled(
'expensereport')) {
2334 print
'<tr><td class="titlefieldcreate">';
2335 $text = $langs->trans(
"ForceUserExpenseValidator");
2336 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2339 if ($caneditfield) {
2340 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_expense_validator,
'fk_user_expense_validator', 1, array($object->id), 0,
'', 0, $object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2342 print
'<input type="hidden" name="fk_user_expense_validator" value="'.$object->fk_user_expense_validator.
'">';
2343 $evuser =
new User($db);
2344 $evuser->fetch($object->fk_user_expense_validator);
2345 print $evuser->getNomUrl(-1);
2352 if (isModEnabled(
'holiday')) {
2353 print
'<tr><td class="titlefieldcreate">';
2354 $text = $langs->trans(
"ForceUserHolidayValidator");
2355 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2358 if ($caneditfield) {
2359 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_holiday_validator,
'fk_user_holiday_validator', 1, array($object->id), 0,
'', 0, $object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2361 print
'<input type="hidden" name="fk_user_holiday_validator" value="'.$object->fk_user_holiday_validator.
'">';
2362 $hvuser =
new User($db);
2363 $hvuser->fetch($object->fk_user_holiday_validator);
2364 print $hvuser->getNomUrl(-1);
2371 print
'<tr><td>'.$langs->trans(
"ExternalUser").
' ?</td>';
2373 if ($user->id == $object->id || !$user->admin) {
2375 $type = $langs->trans(
"Internal");
2376 if ($object->socid) {
2377 $type = $langs->trans(
"External");
2379 print $form->textwithpicto($type, $langs->trans(
"InternalExternalDesc"));
2380 if ($object->ldap_sid) {
2381 print
' ('.$langs->trans(
"DomainUser").
')';
2386 if ($object->contact_id) {
2387 $type = $object->contact_id;
2390 if ($object->socid > 0 && !($object->contact_id > 0)) {
2391 print
img_picto(
'',
'company').$form->select_company($object->socid,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2392 print
img_picto(
'',
'contact').$form->selectcontacts(0, 0,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2393 if ($object->ldap_sid) {
2394 print
' ('.$langs->trans(
"DomainUser").
')';
2396 } elseif ($object->socid > 0 && $object->contact_id > 0) {
2397 print
img_picto(
'',
'company').$form->select_company($object->socid,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2398 print
img_picto(
'',
'contact').$form->selectcontacts(0, $object->contact_id,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2399 if ($object->ldap_sid) {
2400 print
' ('.$langs->trans(
"DomainUser").
')';
2402 } elseif (!($object->socid > 0) && $object->contact_id > 0) {
2403 print
img_picto(
'',
'company').$form->select_company(0,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2404 print
img_picto(
'',
'contact').$form->selectcontacts(0, $object->contact_id,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2405 if ($object->ldap_sid) {
2406 print
' ('.$langs->trans(
"DomainUser").
')';
2409 print
img_picto(
'',
'company').$form->select_company(0,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2410 print
img_picto(
'',
'contact').$form->selectcontacts(0, 0,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2420 print
'<table class="border centpercent">';
2423 print
'<tr><td>'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
2425 if ($caneditfield) {
2426 print $form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity,
'datestartvalidity', 0, 0, 1,
'formdatestartvalidity', 1, 1, 0,
'',
'',
'',
'', 1,
'',
'');
2436 if ($caneditfield) {
2437 print $form->selectDate($dateendvalidity ? $datendevalidity : $object->dateendvalidity,
'dateendvalidity', 0, 0, 1,
'formdateendvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'');
2445 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Password").
'</td>';
2448 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
2449 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
2451 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
2452 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$form->textwithpicto($text, $langs->trans(
"DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1,
'warning');
2454 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication) || preg_match(
'/forceuser/', $dolibarr_main_authentication)) {
2455 if ($caneditpassword) {
2456 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<input maxlength="128" type="password" class="flat" id="password" name="password" value="'.
dol_escape_htmltag($object->pass).
'" autocomplete="new-password">';
2457 if (!empty($conf->use_javascript_ajax)) {
2458 $valuetoshow .=
img_picto((
getDolGlobalString(
'USER_PASSWORD_GENERATED') ===
'none' ? $langs->trans(
'NoPasswordGenerationRuleConfigured') : $langs->trans(
'Generate')),
'refresh',
'id="generate_password" class="paddingleft'.(
getDolGlobalString(
'USER_PASSWORD_GENERATED') ===
'none' ?
' opacitymedium' :
' linkobject').
'"');
2461 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').preg_replace(
'/./i',
'*', $object->pass);
2465 $parameters = array(
'valuetoshow' => $valuetoshow,
'caneditpassword' => $caneditpassword);
2466 $reshook = $hookmanager->executeHooks(
'printUserPasswordField', $parameters, $object, $action);
2468 $valuetoshow = $hookmanager->resPrint;
2470 $valuetoshow .= $hookmanager->resPrint;
2474 print
"</td></tr>\n";
2477 if (isModEnabled(
'api')) {
2478 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
2480 if ($caneditpassword || $user->hasRight(
"api",
"apikey",
"generate")) {
2481 print
'<input class="minwidth300 maxwidth400 widthcentpercentminusx" minlength="12" maxlength="128" type="text" id="api_key" name="api_key" value="'.$object->api_key.
'" autocomplete="off">';
2482 if (!empty($conf->use_javascript_ajax)) {
2483 print
img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject paddingleft"');
2490 if (isset($conf->file->main_authentication) && preg_match(
'/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
2491 print
"<tr>".
'<td>'.$langs->trans(
"OpenIDURL").
'</td>';
2493 if ($caneditfield) {
2494 print
'<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.
'">';
2496 print
'<input type="hidden" name="openid" value="'.$object->openid.
'">';
2497 print $object->openid;
2502 print
'</table><hr><table class="border centpercent">';
2506 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2508 if ($caneditfield) {
2509 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2511 print $object->address;
2512 if ($caneditfield) {
2513 print
'</textarea>';
2518 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
2519 if ($caneditfield) {
2520 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
2527 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
2528 if ($caneditfield) {
2529 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2531 print $object->town;
2536 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td>';
2537 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
2538 if ($caneditfield) {
2539 print $form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $object->country_id),
'country_id');
2541 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2544 $countrylabel =
getCountry($object->country_id,
'0');
2545 print $countrylabel;
2550 if (empty($conf->global->USER_DISABLE_STATE)) {
2551 print
'<tr><td class="tdoverflow">'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td>';
2552 if ($caneditfield) {
2553 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2554 print $formcompany->select_state($object->state_id, $object->country_code,
'state_id');
2556 print $object->state;
2562 print
"<tr>".
'<td>'.$langs->trans(
"PhonePro").
'</td>';
2564 print
img_picto(
'',
'phoning',
'class="pictofixedwidth"');
2565 if ($caneditfield && empty($object->ldap_sid)) {
2566 print
'<input type="text" name="office_phone" class="flat maxwidth200" value="'.$object->office_phone.
'">';
2568 print
'<input type="hidden" name="office_phone" value="'.$object->office_phone.
'">';
2569 print $object->office_phone;
2574 print
"<tr>".
'<td>'.$langs->trans(
"PhoneMobile").
'</td>';
2576 print
img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"');
2577 if ($caneditfield && empty($object->ldap_sid)) {
2578 print
'<input type="text" name="user_mobile" class="flat maxwidth200" value="'.$object->user_mobile.
'">';
2580 print
'<input type="hidden" name="user_mobile" value="'.$object->user_mobile.
'">';
2581 print $object->user_mobile;
2586 print
"<tr>".
'<td>'.$langs->trans(
"Fax").
'</td>';
2588 print
img_picto(
'',
'phoning_fax',
'class="pictofixedwidth"');
2589 if ($caneditfield && empty($object->ldap_sid)) {
2590 print
'<input type="text" name="office_fax" class="flat maxwidth200" value="'.$object->office_fax.
'">';
2592 print
'<input type="hidden" name="office_fax" value="'.$object->office_fax.
'">';
2593 print $object->office_fax;
2598 print
"<tr>".
'<td'.(!empty($conf->global->USER_MAIL_REQUIRED) ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
2600 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2601 if ($caneditfield && empty($object->ldap_sid)) {
2602 print
'<input class="minwidth100 maxwidth500 widthcentpercentminusx" type="text" name="email" class="flat" value="'.$object->email.
'">';
2604 print
'<input type="hidden" name="email" value="'.$object->email.
'">';
2605 print $object->email;
2609 if (isModEnabled(
'socialnetworks')) {
2610 foreach ($socialnetworks as $key => $value) {
2611 if ($value[
'active']) {
2612 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
2614 if (!empty($value[
'icon'])) {
2615 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
2617 if ($caneditfield && empty($object->ldap_sid)) {
2618 print
'<input type="text" name="'.$key.
'" class="flat maxwidth200" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:
'').
'">';
2620 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
2621 print $object->socialnetworks[$key];
2626 print
'<input type="hidden" name="'.$key.
'" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:
'').
'">';
2631 print
'</table><hr><table class="border centpercent">';
2634 if (isModEnabled(
'stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
2635 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2636 print $formproduct->selectWarehouses($object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
2637 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&token='.newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.newToken()).
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2642 if (isModEnabled(
'accounting')) {
2644 print
'<td class="titlefieldcreate">'.$langs->trans(
"AccountancyCode").
'</td>';
2646 if ($caneditfield) {
2647 print
'<input type="text" class="flat maxwidth300" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2649 print
'<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2650 print $object->accountancy_code;
2657 if (isModEnabled(
'agenda')) {
2658 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ColorUser").
'</td>';
2660 if ($caneditfield) {
2661 print $formother->selectColor(GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') : $object->color,
'color', null, 1,
'',
'hideifnotset');
2663 print $formother->showColor($object->color,
'');
2670 print
'<td class="titlefieldcreate">'.$langs->trans(
"Photo").
'</td>';
2672 print $form->showphoto(
'userphoto', $object, 60, 0, $caneditfield,
'photowithmargin',
'small', 1, 0,
'user', 1);
2677 if (isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"read")) {
2678 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td>';
2680 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
2681 $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER,
null,
null,
null,
null, 1);
2683 $cats = $c->containing($object->id, Categorie::TYPE_USER);
2684 $arrayselected = array();
2685 foreach ($cats as $cat) {
2686 $arrayselected[] = $cat->id;
2688 if ($caneditfield) {
2689 print $form->multiselectarray(
'usercats', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'90%');
2691 print $form->showCategories($object->id, Categorie::TYPE_USER, 1);
2698 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0,
'string',
'', 0, 0,
'id', $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup"))).
'</td><td colspan="3">'.
"\n";
2699 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($object->lang,
'default_lang', 0,
null,
'1', 0, 0,
'widthcentpercentminusx maxwidth300');
2705 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
2707 print $object->getLibStatut(4);
2711 if (isModEnabled(
"societe")) {
2712 print
'<tr><td>'.$langs->trans(
"LinkToCompanyContact").
'</td>';
2714 if ($object->socid > 0) {
2716 $societe->fetch($object->socid);
2717 print $societe->getNomUrl(1,
'');
2718 if ($object->contact_id) {
2720 $contact->fetch($object->contact_id);
2721 print
' / <a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$object->contact_id.
'">'.
img_object($langs->trans(
"ShowContact"),
'contact').
' '.
dol_trunc($contact->getFullName($langs), 32).
'</a>';
2724 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ThisUserIsNot").
'</span>';
2726 print
' <span class="opacitymedium hideonsmartphone">('.$langs->trans(
"UseTypeFieldToChange").
')</span>';
2732 if (isModEnabled(
'adherent')) {
2733 $langs->load(
"members");
2734 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
2736 if ($object->fk_member) {
2738 $adh->fetch($object->fk_member);
2739 $adh->ref = $adh->login;
2740 print $adh->getNomUrl(1);
2742 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
2750 if (isModEnabled(
'multicompany') && is_object($mc)) {
2752 if (!method_exists($mc,
'formObjectOptions')) {
2753 if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) {
2754 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
2755 print
"<td>".$mc->select_entities($object->entity,
'entity',
'', 0, 1,
false,
false, 1);
2756 print
"</td></tr>\n";
2758 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
2764 $parameters = array(
'colspan' =>
' colspan="2"');
2766 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2767 print $hookmanager->resPrint;
2768 if (empty($reshook)) {
2769 if ($caneditfield) {
2770 print $object->showOptionals($extrafields,
'edit');
2772 print $object->showOptionals($extrafields,
'view');
2777 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
2779 if ($caneditfield) {
2780 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2782 $doleditor =
new DolEditor(
'signature', $object->signature,
'', 138,
'dolibarr_notes',
'In',
false, $acceptlocallinktomedia, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4,
'90%');
2783 print $doleditor->Create(1);
2795 print
'<table class="border centpercent">';
2801 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
2803 if ($caneditfield) {
2804 print
'<input type="text" class="minwidth300 maxwidth500" name="job" value="'.dol_escape_htmltag($object->job).
'">';
2806 print
'<input type="hidden" name="job" value="'.dol_escape_htmltag($object->job).
'">';
2812 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
2814 if ($caneditfield) {
2815 print
'<input size="8" type="text" name="weeklyhours" value="'.price2num(
GETPOST(
'weeklyhours') ?
GETPOST(
'weeklyhours') : $object->weeklyhours).
'">';
2823 if ((empty($user->socid) && in_array($id, $childids))
2824 || (isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
2825 || (isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
2826 $langs->load(
"salaries");
2829 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
2831 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input size="8" type="text" name="salary" value="'.
price2num(
GETPOST(
'salary') ?
GETPOST(
'salary') : $object->salary).
'">';
2837 $text = $langs->trans(
"THM");
2838 print $form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
2841 if ($caneditfield) {
2842 print
'<input size="8" type="text" name="thm" value="'.price2num(
GETPOST(
'thm') ?
GETPOST(
'thm') : $object->thm).
'">';
2844 print ($object->thm !=
'' ?
price($object->thm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
2851 $text = $langs->trans(
"TJM");
2852 print $form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classthm');
2855 if ($caneditfield) {
2856 print
'<input size="8" type="text" name="tjm" value="'.price2num(
GETPOST(
'tjm') ?
GETPOST(
'tjm') : $object->tjm).
'">';
2858 print ($object->tjm !=
'' ?
price($object->tjm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
2865 print
'<tr><td>'.$langs->trans(
"DateEmployment").
'</td>';
2867 if ($caneditfield) {
2868 print $form->selectDate($dateemployment ? $dateemployment : $object->dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1);
2873 if ($dateemployment && $dateemploymentend) {
2877 if ($caneditfield) {
2878 print $form->selectDate($dateemploymentend ? $dateemploymentend : $object->dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0);
2886 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
2888 if ($caneditfield) {
2889 echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth,
'dateofbirth', 0, 0, 1,
'updateuser', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
2900 print
'<div class="center">';
2901 print
'<input value="'.$langs->trans(
"Save").
'" class="button button-save" type="submit" name="save">';
2902 print
' ';
2903 print
'<input value="'.$langs->trans(
"Cancel").
'" class="button button-cancel" type="submit" name="cancel">';
2909 if ($action !=
'edit' && $action !=
'presend') {
2910 print
'<div class="fichecenter"><div class="fichehalfleft">';
2915 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2916 $genallowed = $user->hasRight(
"user",
"user",
"read");
2917 $delallowed = $user->hasRight(
"user",
"user",
"write");
2919 print $formfile->showdocuments(
'user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', empty($soc->default_lang) ?
'' : $soc->default_lang);
2920 $somethingshown = $formfile->numoffiles;
2923 $linktoelem = $form->showLinkToObjectBlock($object,
null,
null);
2924 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2926 print
'</div><div class="fichehalfright">';
2929 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2931 $somethingshown =
$formactions->showactions($object,
'user', $socid, 1,
'listactions', 0,
'',
'', $object->id);
2933 print
'</div></div>';
2936 if (isModEnabled(
'ldap') && !empty($object->ldap_sid)) {
2943include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
2945if (isModEnabled(
'api')) {
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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage members of a foundation.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage LDAP features.
const SYNCHRO_LDAP_TO_DOLIBARR
Ldap to Dolibarr synchronization.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage user groups.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Make control on an uploaded file from an GUI page and move it to final destination.
acceptLocalLinktoMedia()
Check the syntax of some PHP code.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Ouput javacript to autoset a generated password using default module into a HTML element.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.